diff options
Diffstat (limited to 'Lib/_dummy_thread.py')
-rw-r--r-- | Lib/_dummy_thread.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/_dummy_thread.py b/Lib/_dummy_thread.py index 7aa6579efe4..ed50520ab32 100644 --- a/Lib/_dummy_thread.py +++ b/Lib/_dummy_thread.py @@ -16,7 +16,13 @@ Suggested usage is:: __all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock', 'interrupt_main', 'LockType'] -import traceback as _traceback +# A dummy value +TIMEOUT_MAX = 2**31 + +# NOTE: this module can be imported early in the extension building process, +# and so top level imports of other modules should be avoided. Instead, all +# imports are done when needed on a function-by-function basis. Since threads +# are disabled, the import lock should not be an issue anyway (??). class error(Exception): """Dummy implementation of _thread.error.""" @@ -48,7 +54,8 @@ def start_new_thread(function, args, kwargs={}): except SystemExit: pass except: - _traceback.print_exc() + import traceback + traceback.print_exc() _main = True global _interrupt if _interrupt: @@ -92,7 +99,7 @@ class LockType(object): def __init__(self): self.locked_status = False - def acquire(self, waitflag=None): + def acquire(self, waitflag=None, timeout=-1): """Dummy implementation of acquire(). For blocking calls, self.locked_status is automatically set to @@ -111,6 +118,9 @@ class LockType(object): self.locked_status = True return True else: + if timeout > 0: + import time + time.sleep(timeout) return False __enter__ = acquire |