Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c04957bf
Kaydet (Commit)
c04957bf
authored
Ara 29, 2012
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16641: Fix default values of sched.scheduler.enter arguments were modifiable.
üst
e912496c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
sched.rst
Doc/library/sched.rst
+14
-9
sched.py
Lib/sched.py
+6
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/sched.rst
Dosyayı görüntüle @
c04957bf
...
...
@@ -36,19 +36,22 @@ Example::
>>> import sched, time
>>> s = sched.scheduler(time.time, time.sleep)
>>> def print_time(): print("From print_time", time.time())
>>> def print_time(a='default'):
... print("From print_time", time.time(), a)
...
>>> def print_some_times():
... print(time.time())
... s.enter(5, 1, print_time, ())
... s.enter(10, 1, print_time, ())
... s.enter(10, 1, print_time)
... s.enter(5, 2, print_time, argument=('positional',))
... s.enter(5, 1, print_time, kwargs={'a': 'keyword'})
... s.run()
... print(time.time())
...
>>> print_some_times()
930343690.257
From print_time 930343695.274
From print_time 930343700.273
From print_time 930343695.274 positional
From print_time 930343695.275 keyword
From print_time 930343700.273 default
930343700.276
.. _scheduler-objects:
...
...
@@ -59,7 +62,7 @@ Scheduler Objects
:class:`scheduler` instances have the following methods and attributes:
.. method:: scheduler.enterabs(time, priority, action, argument=
[]
, kwargs={})
.. method:: scheduler.enterabs(time, priority, action, argument=
()
, kwargs={})
Schedule a new event. The *time* argument should be a numeric type compatible
with the return value of the *timefunc* function passed to the constructor.
...
...
@@ -67,8 +70,10 @@ Scheduler Objects
*priority*.
Executing the event means executing ``action(*argument, **kwargs)``.
*argument* must be a sequence holding the parameters for *action*.
*kwargs* must be a dictionary holding the keyword parameters for *action*.
Optional *argument* argument must be a sequence holding the parameters
for *action* if any used.
Optional *kwargs* argument must be a dictionary holding the keyword
parameters for *action* if any used.
Return value is an event which may be used for later cancellation of the event
(see :meth:`cancel`).
...
...
@@ -80,7 +85,7 @@ Scheduler Objects
*kwargs* parameter was added.
.. method:: scheduler.enter(delay, priority, action, argument=
[]
, kwargs={})
.. method:: scheduler.enter(delay, priority, action, argument=
()
, kwargs={})
Schedule an event for *delay* more time units. Other than the relative time, the
other arguments, the effect and the return value are the same as those for
...
...
Lib/sched.py
Dosyayı görüntüle @
c04957bf
...
...
@@ -50,6 +50,8 @@ class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')):
def
__gt__
(
s
,
o
):
return
(
s
.
time
,
s
.
priority
)
>
(
o
.
time
,
o
.
priority
)
def
__ge__
(
s
,
o
):
return
(
s
.
time
,
s
.
priority
)
>=
(
o
.
time
,
o
.
priority
)
_sentinel
=
object
()
class
scheduler
:
def
__init__
(
self
,
timefunc
=
_time
,
delayfunc
=
time
.
sleep
):
...
...
@@ -60,19 +62,21 @@ class scheduler:
self
.
timefunc
=
timefunc
self
.
delayfunc
=
delayfunc
def
enterabs
(
self
,
time
,
priority
,
action
,
argument
=
[],
kwargs
=
{}
):
def
enterabs
(
self
,
time
,
priority
,
action
,
argument
=
(),
kwargs
=
_sentinel
):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
"""
if
kwargs
is
_sentinel
:
kwargs
=
{}
with
self
.
_lock
:
event
=
Event
(
time
,
priority
,
action
,
argument
,
kwargs
)
heapq
.
heappush
(
self
.
_queue
,
event
)
return
event
# The ID
def
enter
(
self
,
delay
,
priority
,
action
,
argument
=
[],
kwargs
=
{}
):
def
enter
(
self
,
delay
,
priority
,
action
,
argument
=
(),
kwargs
=
_sentinel
):
"""A variant that specifies the time as a relative time.
This is actually the more commonly used interface.
...
...
Misc/NEWS
Dosyayı görüntüle @
c04957bf
...
...
@@ -124,6 +124,9 @@ Core and Builtins
Library
-------
- Issue #16641: Fix default values of sched.scheduler.enter arguments were
modifiable.
- Issue #16504: IDLE now catches SyntaxErrors raised by tokenizer. Patch by
Roger Serwy.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment