Commit Graph

167 Commits

Author SHA1 Message Date
Martin Panter 19e69c5a20 Issue #23883: Add missing APIs to __all__; patch by Jacek Kołodziej 2015-11-14 12:46:42 +00:00
Benjamin Peterson 062f4cec5e merge 3.4 (#25362) 2015-10-10 19:36:40 -07:00
Benjamin Peterson 414918a939 use the with statement for locking the internal condition (closes #25362)
Patch by Nir Soffer.
2015-10-10 19:34:46 -07:00
Benjamin Peterson 72181b2f53 merge 3.4 (#25319) 2015-10-05 22:00:33 -07:00
Benjamin Peterson 15982aad2b reinitialize an Event's Condition with a regular lock (closes #25319) 2015-10-05 21:56:22 -07:00
R David Murray f5387c0d6d Merge: #11866: Eliminate race condition in the computation of names for new threads. 2014-10-04 17:45:15 -04:00
R David Murray b186f1df41 #11866: Eliminate race condition in the computation of names for new threads.
Original patch by Peter Saveliev.
2014-10-04 17:43:54 -04:00
Serhiy Storchaka c904e87c13 Issue #22423: Unhandled exception in thread no longer causes unhandled
AttributeError when sys.stderr is None.
2014-09-21 22:09:20 +03:00
Serhiy Storchaka 52005c2e13 Issue #22423: Unhandled exception in thread no longer causes unhandled
AttributeError when sys.stderr is None.
2014-09-21 22:08:13 +03:00
Victor Stinner ae58649721 Issue #22043: time.monotonic() is now always available
threading.Lock.acquire(), threading.RLock.acquire() and socket operations now
use a monotonic clock, instead of the system clock, when a timeout is used.
2014-09-02 23:18:25 +02:00
Antoine Pitrou fa9211b11d Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait() caused by mutation of the waiters queue without holding the lock.
Patch by Doug Zongker.
2014-08-29 23:27:33 +02:00
Antoine Pitrou a64b92edd3 Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait() caused by mutation of the waiters queue without holding the lock.
Patch by Doug Zongker.
2014-08-29 23:26:36 +02:00
Raymond Hettinger 62f4dad816 Issue 21137: Better repr for threading.Lock() 2014-05-25 18:22:35 -07:00
Victor Stinner 7fa767e517 Issue #20976: pyflakes: Remove unused imports 2014-03-20 09:16:38 +01:00
Antoine Pitrou 1095907624 Remove stray semicolon 2014-03-17 18:22:41 +01:00
Tim Peters a577f1e0f1 Changed a comment to end grammar bikeshedding ;-) 2013-10-26 11:56:16 -05:00
Tim Peters 7bad39f174 Fiddled Thread.join() to be a little simpler. Kinda ;-) 2013-10-25 22:33:52 -05:00
Tim Peters e5bb0bf04d Issue #19399: fix sporadic test_subprocess failure.
Change Thread.join() with a negative timeout to just return.  The
behavior isn't documented then, but this restores previous
behavior.
2013-10-25 20:46:51 -05:00
Georg Brandl bb2ed516cc merge with 3.3 2013-10-13 10:44:04 +02:00
Georg Brandl c30b59fe3d Closes #17375: port new threading docstrings from 2.7. 2013-10-13 10:43:59 +02:00
Tim Peters e99bdb9694 Issue 19158: a rare race in BoundedSemaphore could allow .release() too often. 2013-10-08 21:12:58 -05:00
Tim Peters 7634e1cf90 Issue 19158: a rare race in BoundedSemaphore could allow .release() too often. 2013-10-08 20:55:51 -05:00
Tim Peters 72460fa68b Get "stopped" back into repr(Thread) when appropriate.
Due to recent changes, a Thread doesn't know that it's over before
someone calls .join() or .is_alive().  That meant repr(Thread)
continued to include "started" (and not "stopped") before one of
those methods was called, even if hours passed since the thread
ended.

Repaired that.
2013-09-09 18:48:24 -05:00
Tim Peters b5e9ac9ec6 Another stab at the thread cleanup patch.
Antoine Pitrou found a variation that worked for him on the
thread+fork tests, and added an important

    self._is_stopped = True

to the after-fork code.  I confess I don't know why things passed
before.  But then mixing fork with threads is insane ;-)
2013-09-09 14:41:50 -05:00
Tim Peters 7875523f16 Backed out changeset 1f5a7853680c
Unixy buildbots were failing the thread + fork tests :-(
2013-09-09 13:47:16 -05:00
Tim Peters 7a6054b19d Minor cleanup of the new scheme for detecting thread termination.
Documented some obscurities, and assert'ed ._stop()'s crucial precondition.
2013-09-09 12:57:10 -05:00
Tim Peters c363a23eff Issue 18984: Remove ._stopped Event from Thread internals.
The fix for issue 18808 left us checking two things to be sure a Thread
was done:  an Event (._stopped) and a mutex (._tstate_lock).  Clumsy &
brittle.  This patch removes the Event, leaving just a happy lock :-)

The bulk of the patch removes two excruciating tests, which were
verifying sanity of the internals of the ._stopped Event after a fork.
Thanks to Antoine Pitrou for verifying that's the only real value
these tests had.

One consequence of moving from an Event to a mutex:  waiters (threads
calling Thread.join()) used to block each on their own unique mutex
(internal to the ._stopped event), but now all contend on the same
mutex (._tstate_lock).  These approaches have different performance
characteristics on different platforms.  I don't think it matters in
this context.
2013-09-08 18:44:40 -05:00
Antoine Pitrou 5da7e7959e Issue #18808 again: fix the after-fork logic for not-yet-started or already-stopped threads.
(AFAICT, in theory, we must reset all the locks, not just those in use)
2013-09-08 13:19:06 +02:00
Tim Peters 68d7f78703 Issue 18808: blind attempt to repair some buildbot failures.
test_is_alive_after_fork is failing on some old Linux kernels, but
passing on all newer ones.  Since virtually anything can go wrong
with locks when mixing threads with fork, replace the most likely
cause with a redundant simple data member.
2013-09-07 21:23:03 -05:00
Antoine Pitrou 7b4769937f Issue #18808: Thread.join() now waits for the underlying thread state to be destroyed before returning.
This prevents unpredictable aborts in Py_EndInterpreter() when some non-daemon threads are still running.
2013-09-07 23:38:37 +02:00
Andrew Svetlov b1dd5572d3 Add docstring for threading.main_thread(). 2013-09-04 10:33:11 +03:00
Andrew Svetlov 58b5c5ad14 Issue #18882: Add threading.main_thread() function. 2013-09-04 07:01:07 +03:00
Charles-François Natali 79a53ea7d7 Issue #18418: After fork(), reinit all threads states, not only active ones.
Patch by A. Jesse Jiryu Davis.
2013-08-30 23:34:26 +02:00
Charles-François Natali 9939cc89a4 Issue #18418: After fork(), reinit all threads states, not only active ones.
Patch by A. Jesse Jiryu Davis.
2013-08-30 23:32:53 +02:00
Ezio Melotti 9a3777e525 #18705: merge with 3.3. 2013-08-17 15:53:55 +03:00
Ezio Melotti 30b9d5d3af #18705: fix a number of typos. Patch by Févry Thibault. 2013-08-17 15:50:46 +03:00
Brett Cannon cd171c8e92 Issue #18200: Back out usage of ModuleNotFoundError (8d28d44f3a9a) 2013-07-04 17:43:24 -04:00
Brett Cannon 0a140668fa Issue #18200: Update the stdlib (except tests) to use
ModuleNotFoundError.
2013-06-13 20:57:26 -04:00
Serhiy Storchaka b00b596c05 Issue #11714: Use 'with' statements to assure a Semaphore releases a
condition variable.  Original patch by Thomas Rachel.
2013-04-22 22:54:16 +03:00
Serhiy Storchaka 81a5855a27 Issue #11714: Use 'with' statements to assure a Semaphore releases a
condition variable.  Original patch by Thomas Rachel.
2013-04-22 22:51:43 +03:00
R David Murray 5cbf3a0d6e Merge #17435: Don't use mutable default values in Timer.
Patch by Denver Coneybeare with some test modifications by me.
2013-03-30 17:22:30 -04:00
R David Murray 19aeb439c6 Issue #17435: Don't use mutable default values in Timer.
Patch by Denver Coneybeare with some test modifications by me.
2013-03-30 17:19:38 -04:00
Raymond Hettinger 3030728138 Fix import 2013-03-20 19:28:19 -07:00
Raymond Hettinger b65e579926 Improve variable names 2013-03-10 20:34:16 -07:00
Raymond Hettinger ec4b174de4 Issue #17385: Fix quadratic behavior in threading.Condition 2013-03-10 17:57:28 -07:00
Raymond Hettinger 720da57159 Update code to increment and decrement using the cleaner += 1 and -= 1 style. 2013-03-10 15:13:35 -07:00
Victor Stinner ec89539ccc Issue #14428, #14397: Implement the PEP 418
* Rename time.steady() to time.monotonic()
 * On Windows, time.monotonic() uses GetTickCount/GetTickCount64() instead of
   QueryPerformanceCounter()
 * time.monotonic() uses CLOCK_HIGHRES if available
 * Add time.get_clock_info(), time.perf_counter() and time.process_time()
   functions
2012-04-29 02:41:27 +02:00
Antoine Pitrou dd5aa36f17 Issue #14308: Fix an exception when a dummy thread is in the threading module's active list after a fork(). 2012-04-20 00:05:17 +02:00
Antoine Pitrou 8e6e0fdb7f Issue #14308: Fix an exception when a "dummy" thread is in the threading module's active list after a fork(). 2012-04-19 23:55:01 +02:00
Victor Stinner 3d7c878fe3 Issue #14222: Use the new time.steady() function instead of time.time() for
timeout in queue and threading modules to not be affected of system time
update.
2012-03-15 01:22:16 +01:00