]> granicus.if.org Git - python/commitdiff
Use the dummy_thread module in Queue.py and tempfile.py.
authorGuido van Rossum <guido@python.org>
Mon, 30 Dec 2002 22:36:09 +0000 (22:36 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 30 Dec 2002 22:36:09 +0000 (22:36 +0000)
tempfile.py already contained code to let it run without threads present;
for Queue.py this is considered a useful feature too.

Lib/Queue.py
Lib/tempfile.py

index 39c86f2cea7a6a8ec68bb7d50200b27c60abfb89..83a8318f52f691fc936a96f74444d0c31316638e 100644 (file)
@@ -16,7 +16,10 @@ class Queue:
 
         If maxsize is <= 0, the queue size is infinite.
         """
-        import thread
+        try:
+            import thread
+        except ImportError:
+            import dummy_thread as thread
         self._init(maxsize)
         self.mutex = thread.allocate_lock()
         self.esema = thread.allocate_lock()
index 0393ba5d3079d5330d518e3ad7985c3df8938784..d322d8fc4095abc4d27ffff49e24b7dc17ad48d0 100644 (file)
@@ -50,12 +50,9 @@ except (ImportError, AttributeError):
 
 try:
     import thread as _thread
-    _allocate_lock = _thread.allocate_lock
-except (ImportError, AttributeError):
-    class _allocate_lock:
-        def acquire(self):
-            pass
-        release = acquire
+except ImportError:
+    import dummy_thread as _thread
+_allocate_lock = _thread.allocate_lock
 
 _text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
 if hasattr(_os, 'O_NOINHERIT'):