summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove a tuple unpacking in a parameter list to suppress the SyntaxWarning withBrett Cannon2008-08-021-1/+2
| | | | -3.
* Apply patch for 874900: threading module can deadlock after forkJesse Noller2008-07-161-0/+31
|
* add old names back into __all__Benjamin Peterson2008-06-111-1/+2
|
* add aliases to threading moduleBenjamin Peterson2008-06-111-0/+32
|
* give the threading API PEP 8 namesBenjamin Peterson2008-06-111-35/+35
|
* Adds a Thread.getIdent() method to provide the _get_ident() value forGregory P. Smith2008-06-011-2/+10
| | | | any given threading.Thread object. feature request issue 2871.
* #1733757: the interpreter would hang on shutdown, if the function set by ↵Amaury Forgeot d'Arc2008-04-031-7/+8
| | | | | | | | | | | | sys.settrace calls threading.currentThread. The correction somewhat improves the code, but it was close. Many thanks to the "with" construct, which turns python code into C calls. I wonder if it is not better to sys.settrace(None) just after running the __main__ module and before finalization.
* Block the sys.exc_clear -3 warning from threading.py.Jeffrey Yasskin2008-03-311-0/+7
|
* Revert my experiment. I found one reason of failures in test_logging.Amaury Forgeot d'Arc2008-03-291-3/+1
|
* At least let the module compileAmaury Forgeot d'Arc2008-03-291-0/+1
|
* Try to understand why most buildbots suddenly turned to red.Amaury Forgeot d'Arc2008-03-291-1/+2
| | | | | | Undo the only change that might have unexpected effects. To be followed.
* Kill a race in test_threading in which the exception info in a thread finishingJeffrey Yasskin2008-03-281-0/+9
| | | | | | | up after it was joined had a traceback pointing to that thread's (deleted) target attribute, while the test was trying to check that the target was destroyed. Big thanks to Antoine Pitrou for diagnosing the race and pointing out sys.exc_clear() to kill the exception early. This fixes issue 2496.
* Thread.start() used sleep(0.000001) to make sure it didn't return before theJeffrey Yasskin2008-02-281-11/+10
| | | | | | | | | | | | | | | | | | | | | | new thread had started. At least on my MacBook Pro, that wound up sleeping for a full 10ms (probably 1 jiffy). By using an Event instead, we can be absolutely certain that the thread has started, and return more quickly (217us). Before: $ ./python.exe -m timeit -s 'from threading import Thread' 't = Thread(); t.start(); t.join()' 100 loops, best of 3: 10.3 msec per loop $ ./python.exe -m timeit -s 'from threading import Thread; t = Thread()' 't.isAlive()' 1000000 loops, best of 3: 0.47 usec per loop After: $ ./python.exe -m timeit -s 'from threading import Thread' 't = Thread(); t.start(); t.join()' 1000 loops, best of 3: 217 usec per loop $ ./python.exe -m timeit -s 'from threading import Thread; t = Thread()' 't.isAlive()' 1000000 loops, best of 3: 0.86 usec per loop To be fair, the 10ms isn't CPU time, and other threads including the spawned one get to run during it. There are also some slightly more complicated ways to get back the .4us in isAlive() if we want.
* Followup to r61011: Also avoid the reference cycle when the Thread's targetJeffrey Yasskin2008-02-231-5/+7
| | | | raises an exception.
* Prevent classes like:Jeffrey Yasskin2008-02-231-0/+3
| | | | | | | | | | | | | | class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it.
* Revert 60189 and restore performance.Raymond Hettinger2008-01-241-8/+24
|
* - Fix Issue #1703448: A joined thread could show up in theGregory P. Smith2008-01-221-5/+8
| | | | | threading.enumerate() list after the join() for a brief period until it actually exited.
* Replace spam.acquire() try: ... finally: spam.release() with "with spam:"Gregory P. Smith2008-01-221-24/+8
|
* Add a hack (originally devised in a slightly different form by Thomas Wouters)Guido van Rossum2007-08-201-0/+20
| | | | | to prevent spurious tracebacks when a daemon thread's cleanup happens to wake up when the world around it has already been destroyed.
* Eliminate RLock race condition reported in SF bug #1764059Nick Coghlan2007-07-311-1/+2
|
* Patch #1731049: make threading.py use a proper "raise" when checking ↵Collin Winter2007-06-061-12/+23
| | | | internal state, rather than assert statements (which get stripped out by -O).
* Bug #1566280: Explicitly invoke threading._shutdown from Py_Main,Martin v. Löwis2007-01-041-5/+5
| | | | | to avoid relying on atexit. Will backport to 2.5.
* Patch #1454481: Make thread stack size runtime tunable.Andrew MacIntyre2006-06-131-1/+3
| | | | | | | | | | Heavily revised, comprising revisions: 46640 - original trunk revision (backed out in r46655) 46647 - markup fix (backed out in r46655) 46692:46918 merged from branch aimacintyre-sf1454481 branch tested on buildbots (Windows buildbots had problems not related to these changes).
* Revert revisions:Tim Peters2006-06-041-3/+1
| | | | | | | | | | | | | | | | 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch.
* Patch #1454481: Make thread stack size runtime tunable.Andrew MacIntyre2006-06-041-1/+3
|
* Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum2006-05-021-8/+5
| | | | | | | | discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself.
* Implement MvL's improvement on __context__ in Condition;Guido van Rossum2006-04-251-5/+1
| | | | | this can just call __context__ on the underlying lock. (The same change for Semaphore does *not* work!)
* Um, I thought I'd already checked this in.Guido van Rossum2006-03-101-6/+0
| | | | | | | Anyway, this is the changes to the with-statement so that __exit__ must return a true value in order for a pending exception to be ignored. The PEP (343) is already updated.
* Updates to the with-statement:Guido van Rossum2006-02-281-0/+29
| | | | | | | | | | | | | | | | - New semantics for __exit__() -- it must re-raise the exception if type is not None; the with-statement itself doesn't do this. (See the updated PEP for motivation.) - Added context managers to: - file - thread.LockType - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore} - decimal.Context - Added contextlib.py, which defines @contextmanager, nested(), closing(). - Unit tests all around; bot no docs yet.
* Prevent threading.Thread.join() from blocking when a previous call raised anBrett Cannon2005-11-231-16/+18
| | | | | | exception (e.g., passing in an illegal argument). Applies patch #1314396. Thanks Eric Blossom.
* bug [ 1238170 ] threading.Thread uses {} as default argumentGeorg Brandl2005-07-151-1/+3
|
* Fixed typo in verbose output.Brett Cannon2005-01-271-1/+1
| | | | Closes bug #1110998. Thanks Matthew Bogosian.
* threading._DummyThread.__init__(): document obscure new code.Tim Peters2005-01-081-3/+9
| | | | | | | | test_threading.test_foreign_thread(): new test does a basic check that "foreign" threads can using the threading module, and that they create a _DummyThread instance in at least one use case. This isn't a very good test, since a thread created by thread.start_new_thread() isn't particularly "foreign".
* In _DummyThread objects the lock stored in __block (allocated thanks toBrett Cannon2005-01-081-0/+1
| | | | | | | | _Thread.__init__) was never used. This is a waste since locks use OS primitives that are in limited supply. So the lock is deleted in _DummyThread.__init__ . Closes bug #1089632.
* Thread.__delete: Discussion of internal obscurities belongs in commentsTim Peters2004-07-211-31/+28
| | | | | | | | rather than in docstrings. Rewrote so that _active_limbo_lock is released no matter what happens (it could have been left locked if _sys got None'd out). Use "in" in preference to has_key() for dict lookup. Don't bother looking for 'dummy_threading' in sys.modules unless KeyError is raised. Since the heart of the method is the del, do that in only one place.
* Fix bug where a KeyError was raised if -O was being used for the interpreterBrett Cannon2004-07-211-1/+33
| | | | | | | | | and Thread.__delete() was called after a Thread instance was created. Problem resulted from a currentThread() call in an 'assert' statement being optimized out and dummy_thread.get_ident() always returning -1 and thus overwriting the entry for the _MainThread() instance created in 'threading' at import time. Closes bug #993394.
* Implemented thread-local data as proposed on python-dev:Jim Fulton2004-07-141-1/+9
| | | | http://mail.python.org/pipermail/python-dev/2004-June/045785.html
* threading.Thread objects will now print a traceback for an exception raisedBrett Cannon2004-07-031-2/+38
| | | | | | | during interpreter shutdown instead of masking it with another traceback about accessing a NoneType when trying to print the exception out in the first place. Closes bug #754449 (using patch #954922).
* Remove calls to currentThread() in _Condition methods that were side-effect.Brett Cannon2004-03-081-2/+0
| | | | | | | | | Side-effects were deemed unnecessary and were causing problems at shutdown time when threads were catching exceptions at start time and then triggering exceptions trying to call currentThread() after gc'ed. Masked the initial exception which was deemed bad. Fixes bug #754449 .
* * Move collections.deque() in from the sandboxRaymond Hettinger2004-01-291-2/+3
| | | | | | * Add unittests, newsitem, and whatsnew * Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py * Docs are forthcoming
* Add traceback.format_exc().Neil Schemenauer2003-11-051-5/+2
|
* Make the classes exposed by threading.py new-style classes. This isTim Peters2003-07-011-3/+7
| | | | mostly for convenience and to aid debugging.
* Resolved minor XXX question in the obvious way.Tim Peters2003-07-011-1/+1
|
* Whitespace normalization.Tim Peters2003-06-291-2/+2
|
* Remove stub settrace() and setprofile() calls.Jeremy Hylton2003-06-291-8/+0
|
* Add settrace() and setprofile() functions to the threading library.Jeremy Hylton2003-06-291-0/+20
|
* Provide dummy (do-nothing) settrace() and setprofile() functions untilTim Peters2003-06-291-1/+9
| | | | Jeremy can check in the real things.
* Get rid of many apply() calls.Guido van Rossum2003-02-271-6/+6
|
* - prefer "import ... as" to "import / (assignments) / del" for most thingsFred Drake2002-12-301-18/+11
| | | | | - when the thread module isn't available, subsequent attempts to import threading should not suceed
* Add __all__. (Brett Cannon.)Guido van Rossum2002-12-301-0/+2
|