From: Guido van Rossum Date: Mon, 30 Dec 2002 22:36:09 +0000 (+0000) Subject: Use the dummy_thread module in Queue.py and tempfile.py. X-Git-Tag: v2.3c1~2783 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0934246d3ee4061e93805d056759f3f40ec45de;p=thirdparty%2FPython%2Fcpython.git Use the dummy_thread module in Queue.py and tempfile.py. tempfile.py already contained code to let it run without threads present; for Queue.py this is considered a useful feature too. --- diff --git a/Lib/Queue.py b/Lib/Queue.py index 39c86f2cea7a..83a8318f52f6 100644 --- a/Lib/Queue.py +++ b/Lib/Queue.py @@ -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() diff --git a/Lib/tempfile.py b/Lib/tempfile.py index 0393ba5d3079..d322d8fc4095 100644 --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -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'):