[Python-checkins] python/dist/src/Lib dummy_threading.py,1.1,1.2

dcjim at users.sourceforge.net dcjim at users.sourceforge.net
Wed Jul 14 21:11:52 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16836/Lib

Modified Files:
	dummy_threading.py 
Log Message:
Implemented thread-local data as proposed on python-dev:

http://mail.python.org/pipermail/python-dev/2004-June/045785.html


Index: dummy_threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dummy_threading.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dummy_threading.py	30 Dec 2002 22:30:22 -0000	1.1
--- dummy_threading.py	14 Jul 2004 19:11:50 -0000	1.2
***************
*** 19,22 ****
--- 19,23 ----
  holding_thread = False
  holding_threading = False
+ holding__threading_local = False
  
  try:
***************
*** 38,45 ****
--- 39,57 ----
          holding_threading = True
          del sys_modules['threading']
+ 
+     if '_threading_local' in sys_modules:
+         # If ``_threading_local`` is already imported, might as well prevent
+         # trying to import it more than needed by saving it if it is
+         # already imported before deleting it.
+         held__threading_local = sys_modules['_threading_local']
+         holding__threading_local = True
+         del sys_modules['_threading_local']
+         
      import threading
      # Need a copy of the code kept somewhere...
      sys_modules['_dummy_threading'] = sys_modules['threading']
      del sys_modules['threading']
+     sys_modules['_dummy__threading_local'] = sys_modules['_threading_local']
+     del sys_modules['_threading_local']
      from _dummy_threading import *
      from _dummy_threading import __all__
***************
*** 47,50 ****
--- 59,63 ----
  finally:
      # Put back ``threading`` if we overwrote earlier
+ 
      if holding_threading:
          sys_modules['threading'] = held_threading
***************
*** 52,55 ****
--- 65,75 ----
      del holding_threading
  
+     # Put back ``_threading_local`` if we overwrote earlier
+ 
+     if holding__threading_local:
+         sys_modules['_threading_local'] = held__threading_local
+         del held__threading_local
+     del holding__threading_local
+ 
      # Put back ``thread`` if we overwrote, else del the entry we made
      if holding_thread:



More information about the Python-checkins mailing list