Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a093424

Browse files
committed
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.
1 parent 2969233 commit a093424

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/Queue.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def __init__(self, maxsize=0):
1616
1717
If maxsize is <= 0, the queue size is infinite.
1818
"""
19-
import thread
19+
try:
20+
import thread
21+
except ImportError:
22+
import dummy_thread as thread
2023
self._init(maxsize)
2124
self.mutex = thread.allocate_lock()
2225
self.esema = thread.allocate_lock()

Lib/tempfile.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ def _set_cloexec(fd):
5050

5151
try:
5252
import thread as _thread
53-
_allocate_lock = _thread.allocate_lock
54-
except (ImportError, AttributeError):
55-
class _allocate_lock:
56-
def acquire(self):
57-
pass
58-
release = acquire
53+
except ImportError:
54+
import dummy_thread as _thread
55+
_allocate_lock = _thread.allocate_lock
5956

6057
_text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
6158
if hasattr(_os, 'O_NOINHERIT'):

0 commit comments

Comments
 (0)