summaryrefslogtreecommitdiffstats
path: root/Doc/library/sched.rst
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2011-12-14 12:34:26 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2011-12-14 12:34:26 (GMT)
commit73520d57ebfb1272d009a070191e749caebf64ae (patch)
tree1a8febdb66d40004af7a2668bd5b7d1249602cf5 /Doc/library/sched.rst
parenta23d65ccfe3b8f618bf3dde4d0d27895e764367e (diff)
downloadcpython-73520d57ebfb1272d009a070191e749caebf64ae.zip
cpython-73520d57ebfb1272d009a070191e749caebf64ae.tar.gz
cpython-73520d57ebfb1272d009a070191e749caebf64ae.tar.bz2
Fix #8684: make sched.scheduler class thread-safe
Diffstat (limited to 'Doc/library/sched.rst')
-rw-r--r--Doc/library/sched.rst30
1 files changed, 3 insertions, 27 deletions
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst
index a644ed2..455cc70 100644
--- a/Doc/library/sched.rst
+++ b/Doc/library/sched.rst
@@ -27,6 +27,9 @@ scheduler:
.. versionchanged:: 3.3
*timefunc* and *delayfunc* parameters are optional.
+ .. versionchanged:: 3.3
+ :class:`scheduler` class can be safely used in multi-threaded
+ environments.
Example::
@@ -47,33 +50,6 @@ Example::
From print_time 930343700.273
930343700.276
-In multi-threaded environments, the :class:`scheduler` class has limitations
-with respect to thread-safety, inability to insert a new task before
-the one currently pending in a running scheduler, and holding up the main
-thread until the event queue is empty. Instead, the preferred approach
-is to use the :class:`threading.Timer` class instead.
-
-Example::
-
- >>> import time
- >>> from threading import Timer
- >>> def print_time():
- ... print("From print_time", time.time())
- ...
- >>> def print_some_times():
- ... print(time.time())
- ... Timer(5, print_time, ()).start()
- ... Timer(10, print_time, ()).start()
- ... time.sleep(11) # sleep while time-delay events execute
- ... print(time.time())
- ...
- >>> print_some_times()
- 930343690.257
- From print_time 930343695.274
- From print_time 930343700.273
- 930343701.301
-
-
.. _scheduler-objects:
Scheduler Objects