[Stackless-checkins] r51753 - stackless/sandbox/libraries/slpmonkeypatch/__init__.py

richard.tew python-checkins at python.org
Tue Sep 5 21:41:34 CEST 2006


Author: richard.tew
Date: Tue Sep  5 21:41:33 2006
New Revision: 51753

Modified:
   stackless/sandbox/libraries/slpmonkeypatch/__init__.py
Log:
Clean up initialisation of the stackless._config threading local object.

Modified: stackless/sandbox/libraries/slpmonkeypatch/__init__.py
==============================================================================
--- stackless/sandbox/libraries/slpmonkeypatch/__init__.py	(original)
+++ stackless/sandbox/libraries/slpmonkeypatch/__init__.py	Tue Sep  5 21:41:33 2006
@@ -4,13 +4,18 @@
 import threading
 import socket as stdsocket
 
-_config = stackless._config = threading.local()
-
 def register_thread_for_stackless():
-  _config.using_stackless = True
-  _config.emulation_timeout = 0.1
+    _config = getattr(stackless, "_config", None)
+    if _config is None:
+        _config = stackless._config = threading.local()
+    _config.using_stackless = True
+    _config.emulation_timeout = 0.1
 
 def monkeypatch():
+    # This thread is the only automatically registered one.
+    stackless.register_thread = register_thread_for_stackless
+    stackless.register_thread()
+
     # Go through some shenanigans to get the path to the 'examples'
     # directory in the SVN 'sandbox' directory structure.
     filePath = os.path.join(os.getcwd(), __file__)
@@ -37,9 +42,4 @@
     import socketmodule
     sys.modules["socket"] = socketmodule
 
-    stackless.register_thread = register_thread_for_stackless
-
-    # This thread is the only automatically registered one.
-    stackless.register_thread()
-
 

_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins



More information about the Stackless-checkins mailing list