mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Implemented thread-local data as proposed on python-dev:
http://mail.python.org/pipermail/python-dev/2004-June/045785.html
This commit is contained in:
parent
e827437f45
commit
d15dc06df0
6 changed files with 571 additions and 1 deletions
|
@ -15,7 +15,7 @@ from collections import deque
|
|||
# Rename some stuff so "from threading import *" is safe
|
||||
__all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event',
|
||||
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
|
||||
'Timer', 'setprofile', 'settrace']
|
||||
'Timer', 'setprofile', 'settrace', 'local']
|
||||
|
||||
_start_new_thread = thread.start_new_thread
|
||||
_allocate_lock = thread.allocate_lock
|
||||
|
@ -661,6 +661,14 @@ def enumerate():
|
|||
|
||||
_MainThread()
|
||||
|
||||
# get thread-local implementation, either from the thread
|
||||
# module, or from the python fallback
|
||||
|
||||
try:
|
||||
from thread import _local as local
|
||||
except ImportError:
|
||||
from _threading_local import local
|
||||
|
||||
|
||||
# Self-test code
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue