summaryrefslogtreecommitdiff
path: root/Modules/_threadmodule.c
AgeCommit message (Collapse)AuthorLines
2018-12-10bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)Miss Islington (bot)-3/+5
* bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference. (cherry picked from commit 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-09-10[3.7] Fix misleading mentions of tp_size in comments. (GH-9136)Benjamin Peterson-2/+2
Many type object initializations labeled a field "tp_size" in the comment, but the name of that field is tp_basicsize.. (cherry picked from commit 0e0bc4e221f592f305d335faf5f8046484eb9238) Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
2018-01-16bpo-32544: Speed up hasattr() and getattr() (GH-5173)INADA Naoki-2/+4
AttributeError was raised always when attribute is not found. This commit skip raising AttributeError when `tp_getattro` is `PyObject_GenericGetAttr`. It makes hasattr() and getattr() about 4x faster when attribute is not found.
2017-11-30Fix CID-1420310: cast PY_TIMEOUT_MAX to _Py_time_t (#4646)Victor Stinner-1/+1
Fix the following false-alarm Coverity warning: Result is not floating-point (UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer expressions 9223372036854775807LL and 1000LL, and then converting the integer quotient to type double. Any remainder, or fractional part of the quotient, is ignored. To compute and use a non-integer quotient, change or cast either operand to type double. If integer division is intended, consider indicating that by casting the result to type long long .
2017-11-08Replace KB unit with KiB (#4293)Victor Stinner-2/+2
kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte") means 1024 bytes. KB was misused: replace kB or KB with KiB when appropriate. Same change for MB and GB which become MiB and GiB. Change the output of Tools/iobench/iobench.py. Round also the size of the documentation from 5.5 MB to 5 MiB.
2017-10-24bpo-30768: Recompute timeout on interrupted lock (GH-4103)Victor Stinner-2/+4
Fix the pthread+semaphore implementation of PyThread_acquire_lock_timed() when called with timeout > 0 and intr_flag=0: recompute the timeout if sem_timedwait() is interrupted by a signal (EINTR). See also the PEP 475. The pthread implementation of PyThread_acquire_lock() now fails with a fatal error if the timeout is larger than PY_TIMEOUT_MAX, as done in the Windows implementation. The check prevents any risk of overflow in PyThread_acquire_lock(). Add also PY_DWORD_MAX constant.
2017-10-18bpo-31806: Use _PyTime_ROUND_TIMEOUT for the timeout argument parsing in ↵Pablo Galindo-2/+2
more functions (#4026) Fix timeout rounding in time.sleep(), threading.Lock.acquire() and socket.socket.settimeout() to round correctly negative timeouts between -1.0 and 0.0. The functions now block waiting for events as expected. Previously, the call was incorrectly non-blocking.
2017-09-07bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow-5/+7
* group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-07bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou-7/+0
* Remove Setup.config * Always define WITH_THREAD for compatibility.
2017-09-05Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)Eric Snow-6/+5
Windows buildbots started failing due to include-related errors.
2017-09-05bpo-30860: Consolidate stateful runtime globals. (#2594)Eric Snow-5/+6
* group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
2017-03-23bpo-6532: Make the thread id an unsigned integer. (#781)Serhiy Storchaka-15/+14
* bpo-6532: Make the thread id an unsigned integer. From C API side the type of results of PyThread_start_new_thread() and PyThread_get_thread_ident(), the id parameter of PyThreadState_SetAsyncExc(), and the thread_id field of PyThreadState changed from "long" to "unsigned long". * Restore a check in thread_get_ident().
2017-02-16bpo-29548: Fix some inefficient call API usage (GH-97)INADA Naoki-2/+1
2017-01-23Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka-4/+2
possible. Patch is writen with Coccinelle.
2016-08-30Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger-1/+1
2016-05-02Issue #18916: Update thread module docstringsBerker Peksag-3/+4
* Fix acquire() signature * Remove outdated help(LockType) reference * Replace PyThread_allocate_lock() with threading.Lock() Patch by Christopher Welborn.
2015-05-30Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka-6/+12
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
2015-05-30Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka-6/+12
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
2015-04-03Issue #22117: Add a new _PyTime_FromSeconds() functionVictor Stinner-1/+1
Fix also _Py_InitializeEx_Private(): initialize time before initializing import, import_init() uses the _PyTime API (for thread locks).
2015-03-30PEP 475: on EINTR, retry the function even if the timeout is equals to zeroVictor Stinner-1/+1
Retry: * signal.sigtimedwait() * threading.Lock.acquire() * threading.RLock.acquire() * time.sleep()
2015-03-30Issue #22117: Replace usage of _PyTime_ROUND_UP with _PyTime_ROUND_CEILINGVictor Stinner-3/+4
All these functions only accept positive timeouts, so this change has no effect in practice.
2015-03-28Issue #22117: The thread module uses the new _PyTime_t timestamp APIVictor Stinner-75/+64
Add also a new _PyTime_AsMicroseconds() function. threading.TIMEOUT_MAX is now be smaller: only 292 years instead of 292,271 years on 64-bit system for example. Sorry, your threads will hang a *little bit* shorter. Call me if you want to ensure that your locks wait longer, I can share some tricks with you.
2014-09-02Issue #22043: time.monotonic() is now always availableVictor Stinner-2/+2
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-05-25Issue 21137: Better repr for threading.Lock()Raymond Hettinger-3/+12
2014-01-02threading.RLock._acquire_restore() now raises a TypeError instead of aVictor Stinner-3/+3
SystemError when it is not called with 2 arguments
2013-11-07Issue #19512, #19515: remove shared identifiers, move identifiers where theyVictor Stinner-1/+3
are used. Move also _Py_IDENTIFIER() defintions to the top in modified files to remove identifiers duplicated in the same file.
2013-11-06Issue #19512: add some common identifiers to only create common strings once,Victor Stinner-1/+1
instead of creating temporary Unicode string objects Add also more identifiers in pythonrun.c to avoid temporary Unicode string objets for the interactive interpreter.
2013-11-05Issue #19437: Fix _threading.RLock constructor (rlock_new), callVictor Stinner-10/+14
Py_DECREF(self) if PyThread_allocate_lock() failed instead of calling directly type->tp_free(self), to keep the chained list of objects consistent when Python is compiled in debug mode fails, don't consume the row (restore it) and fail immediatly (don't call pysqlite_step())
2013-09-07Issue #18808: Thread.join() now waits for the underlying thread state to be ↵Antoine Pitrou-0/+62
destroyed before returning. This prevents unpredictable aborts in Py_EndInterpreter() when some non-daemon threads are still running.
2013-02-04merge #17091: update docstring for _thread.Lock.acquire.R David Murray-2/+2
2013-02-04merge #17091: update docstring for _thread.Lock.acquire.R David Murray-2/+2
2013-02-04#17091: update docstring for _thread.Lock.acquire.R David Murray-2/+2
The main docs were fixed to remove mention of None long ago, but the docstring was not. Reported by Armin Rigo, patch by Ian Cordasco.
2012-12-25Issue #15422: get rid of PyCFunction_New macroAndrew Svetlov-1/+1
2012-06-22Issue #15124: Optimize _thread.LockType deletion and acquisition whenKristjan Valur Jonsson-21/+17
not contested, similar to what _thread.RLock already has.
2012-04-02merge 3.2Benjamin Peterson-0/+3
2012-04-02prevent writing to stderr from messing up the exception state (closes #14474)Benjamin Peterson-0/+3
2011-06-01Merge 3.2Éric Araujo-1/+1
2011-05-31Fix error message to use the Python name instead of the C nameÉric Araujo-1/+1
2011-04-30Issue #11223: Replace threading._info() by sys.thread_infoVictor Stinner-13/+0
2011-04-24Issue #11915: threading.RLock()._release_save() raises a RuntimeError if theVictor Stinner-0/+6
lock was not acquired.
2011-04-19Issue #11223: Add threading._info() function providing informations about theVictor Stinner-7/+17
thread implementation. Skip test_lock_acquire_interruption() and test_rlock_acquire_interruption() of test_threadsignals if a thread lock is implemented using a POSIX mutex and a POSIX condition variable. A POSIX condition variable cannot be interrupted by a signal (e.g. on Linux, the futex system call is restarted).
2011-03-15#11515: Merge with 3.1.Ezio Melotti-1/+1
2011-03-15#11515: fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti-1/+1
2011-03-15#11515: Merge with 3.2.Ezio Melotti-1/+1
2011-03-06Issue #11408: In threading.Lock.acquire(), only call gettimeofday() whenAntoine Pitrou-2/+2
really necessary. Patch by Charles-François Natali.
2011-02-28Issue #11140: Lock.release() now raises a RuntimeError when attemptingAntoine Pitrou-1/+3
to release an unacquired lock, as claimed in the threading documentation. The _thread.error exception is now an alias of RuntimeError.
2011-02-22Issue #8914: fix various warnings from the Clang static analyzer v254.Brett Cannon-1/+2
2010-12-15Issue #8844: Regular and recursive lock acquisitions can now be interruptedAntoine Pitrou-13/+67
by signals on platforms using pthreads. Patch by Reid Kleckner.
2010-08-28Merged revisions 84344 via svnmerge fromAntoine Pitrou-43/+38
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84344 | antoine.pitrou | 2010-08-28 20:17:03 +0200 (sam., 28 août 2010) | 4 lines Issue #1868: Eliminate subtle timing issues in thread-local objects by getting rid of the cached copy of thread-local attribute dictionary. ........
2010-08-28Issue #1868: Eliminate subtle timing issues in thread-local objects byAntoine Pitrou-43/+38
getting rid of the cached copy of thread-local attribute dictionary.