86 Commits

Author SHA1 Message Date
Antoine Pitrou
9fb1aca5d8 Backport relevant part of r66274 (in issue #874900). 2008-09-06 23:04:32 +00:00
Benjamin Peterson
973e6c2cf3 remove py3k warnings about the threading api; update docs
Reviewer: Benjamin Peterson
2008-09-01 23:12:58 +00:00
Benjamin Peterson
b6a955672f fix a few get_name() calls and turn then to .name
Reviewer: Christian Heimes
2008-08-22 20:43:48 +00:00
Benjamin Peterson
6ee1a31e9b add py3k warnings for old threading APIs
they will still live in 3.0 but it can't hurt
2008-08-18 21:53:29 +00:00
Benjamin Peterson
d810626f99 bring back the old API 2008-08-18 18:13:17 +00:00
Benjamin Peterson
cbae869759 backport threading property changes 2008-08-18 17:45:09 +00:00
Benjamin Peterson
d8a8972ca9 change threading.getIdent to a property
This is new in 2.6 so now need to worry about backwards compatibility :)
2008-08-18 16:40:03 +00:00
Brett Cannon
2005050152 Remove a tuple unpacking in a parameter list to suppress the SyntaxWarning with
-3.
2008-08-02 03:13:46 +00:00
Jesse Noller
5e62ca4fea Apply patch for 874900: threading module can deadlock after fork 2008-07-16 20:03:47 +00:00
Benjamin Peterson
13f7382e0d add old names back into __all__ 2008-06-11 18:02:31 +00:00
Benjamin Peterson
f439560265 add aliases to threading module 2008-06-11 17:50:00 +00:00
Benjamin Peterson
0fbcf69455 give the threading API PEP 8 names 2008-06-11 17:27:50 +00:00
Gregory P. Smith
8856ddae25 Adds a Thread.getIdent() method to provide the _get_ident() value for
any given threading.Thread object.  feature request issue 2871.
2008-06-01 23:48:47 +00:00
Amaury Forgeot d'Arc
d7a265129c #1733757: the interpreter would hang on shutdown, if the function set by 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.
2008-04-03 23:07:55 +00:00
Jeffrey Yasskin
105f3d4fdc Block the sys.exc_clear -3 warning from threading.py. 2008-03-31 00:35:53 +00:00
Amaury Forgeot d'Arc
504a48f90a Revert my experiment. I found one reason of failures in test_logging. 2008-03-29 01:41:08 +00:00
Amaury Forgeot d'Arc
554d4f0c13 At least let the module compile 2008-03-29 00:49:07 +00:00
Amaury Forgeot d'Arc
8a69707b80 Try to understand why most buildbots suddenly turned to red.
Undo the only change that might have unexpected effects.

To be followed.
2008-03-29 00:44:58 +00:00
Jeffrey Yasskin
8b9091fba0 Kill a race in test_threading in which the exception info in a thread finishing
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.
2008-03-28 04:11:18 +00:00
Jeffrey Yasskin
69e1309fd4 Thread.start() used sleep(0.000001) to make sure it didn't return before the
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.
2008-02-28 06:09:19 +00:00
Jeffrey Yasskin
a885c1521a Followup to r61011: Also avoid the reference cycle when the Thread's target
raises an exception.
2008-02-23 20:40:35 +00:00
Jeffrey Yasskin
3414ea9ed9 Prevent classes like:
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.
2008-02-23 19:40:54 +00:00
Raymond Hettinger
70ec29d0f4 Revert 60189 and restore performance. 2008-01-24 18:12:23 +00:00
Gregory P. Smith
95cd5c0b72 - Fix Issue #1703448: A joined thread could show up in the
threading.enumerate() list after the join() for a brief period until
  it actually exited.
2008-01-22 01:20:42 +00:00
Gregory P. Smith
64c5677de4 Replace spam.acquire() try: ... finally: spam.release() with "with spam:" 2008-01-22 01:12:02 +00:00