Commit Graph

17 Commits

Author SHA1 Message Date
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
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
Amaury Forgeot d'Arc 025c347d61 Issue #1402: PyInterpreterState_Clear() may still invoke user code
(in deallocation of running threads, for example), so the PyGILState_Release()
function must still be functional.
On the other hand, _PyGILState_Fini() only frees memory, and can be called later.

Backport candidate, but only after some experts comment on it.
2007-11-29 23:35:25 +00:00
Collin Winter 50b79ce8e6 Patch #1731049: make threading.py use a proper "raise" when checking internal state, rather than assert statements (which get stripped out by -O). 2007-06-06 00:17:35 +00:00
Tim Peters 08574770c5 test_PyThreadState_SetAsyncExc(): This is failing on some
64-bit boxes.  I have no idea what the ctypes docs mean
by "integers", and blind-guessing here that it intended to
mean the signed C "int" type, in which case perhaps I can
repair this by feeding the thread id argument to type
ctypes.c_long().

Also made the worker thread daemonic, so it doesn't hang
Python shutdown if the test continues to fail.
2006-08-11 00:49:01 +00:00
Tim Peters 4643c2fda1 Followup to bug #1069160.
PyThreadState_SetAsyncExc():  internal correctness changes wrt
refcount safety and deadlock avoidance.  Also added a basic test
case (relying on ctypes) and repaired the docs.
2006-08-10 22:45:34 +00:00
Andrew MacIntyre 16ee33adfc test_threading now skips testing alternate thread stack sizes on
platforms that don't support changing thread stack size.
2006-08-06 12:37:03 +00:00
Andrew MacIntyre 93e3ecb1f4 Increase the small thread stack size to get the test
to pass reliably on the one buildbot that insists on
more than 32kB of thread stack.
2006-06-13 19:02:35 +00:00
Andrew MacIntyre 9291332de1 Patch #1454481: Make thread stack size runtime tunable.
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).
2006-06-13 15:04:24 +00:00
Tim Peters 28eeefe566 Revert revisions:
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.
2006-06-04 23:52:47 +00:00
Andrew MacIntyre 6539d2d3c7 Patch #1454481: Make thread stack size runtime tunable. 2006-06-04 12:31:09 +00:00
Tim Peters 711906e0c2 threading._DummyThread.__init__(): document obscure new code.
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".
2005-01-08 07:30:42 +00:00
Tim Peters 84d548994e Converted to a unittest. Added checks that the bounded semaphore actually
does what it's supposed to do.
2005-01-08 06:03:17 +00:00
Barry Warsaw 04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Tim Peters 02035bc68d Test failed because these was no expected-output file, but always printed
to stdout.  Repaired by not printing at all except in verbose mode.

Made the test about 6x faster -- envelope analysis showed it took time
proportional to the square of the # of tasks.  Now it's linear.
2001-08-20 21:45:19 +00:00
Skip Montanaro 4533f60da5 add a few test cases for threading module. 2001-08-20 20:28:48 +00:00