mò %U²Ic@s¢dZdZdZddddddd gZd kZdefd „ƒYZhd „Zd „Z d„Z d„Z d e fd„ƒYZ eaead„Zd S(s,Drop-in replacement for the thread module. Meant to be used as a brain-dead substitute so that threaded code does not need to be rewritten for when the thread module is not present. Suggested usage is:: try: import thread except ImportError: import dummy_thread as thread s Brett Cannonsbrett@python.orgterrortstart_new_threadtexitt get_identt allocate_locktinterrupt_maintLockTypeNcBstZdZd„ZRS(s%Dummy implementation of thread.error.cGs ||_dS(N(targstself(RR((t)/data/zmath/lib/python2.4/dummy_thread.pyt__init__s(t__name__t __module__t__doc__R (((R Rs cCs¶t|ƒttƒƒjotdƒ‚nt|ƒttƒƒjotdƒ‚ntay|||ŽWn#t j ont i ƒnXt at ota t‚ndS(säDummy implementation of thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by thread.exit()) it is caught and nothing is done; all other exceptions are printed out by using traceback.print_exc(). If the executed function calls interrupt_main the KeyboardInterrupt will be raised when the function returns. s2nd arg must be a tuples3rd arg must be a dictN(ttypeRttuplet TypeErrortkwargstdicttFalset_maintfunctiont SystemExitt _tracebackt print_exctTruet _interrupttKeyboardInterrupt(RRR((R Rs$ cCs t‚dS(s&Dummy implementation of thread.exit().N(R(((R R=scCsdS(sòDummy implementation of thread.get_ident(). Since this module should only be used when threadmodule is not available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned. iÿÿÿÿN((((R RAscCstƒS(s/Dummy implementation of thread.allocate_lock().N(R(((R RJscBs5tZdZd„Zed„Zd„Zd„ZRS(s‹Class implementing dummy implementation of thread.LockType. Compatibility is maintained by maintaining self.locked_status which is a boolean that stores the state of the lock. Pickling of the lock, though, should not be done since if the thread module is then used with an unpickled ``lock()`` from here problems could occur from this class not having atomic methods. cCs t|_dS(N(RRt locked_status(R((R R YscCsY|djot|_dSn8|p#|ipt|_tSqUtSnt|_tSdS(s©Dummy implementation of acquire(). For blocking calls, self.locked_status is automatically set to True and returned appropriately based on value of ``waitflag``. If it is non-blocking, then the value is actually checked and not set if it is already acquired. This is all done so that threading.Condition's assert statements aren't triggered and throw a little fit. N(twaitflagtNoneRRRR(RR((R tacquire\s      cCs!|ip t‚nt|_tS(sRelease the dummy lock.N(RRRRR(R((R treleasets    cCs|iS(N(RR(R((R tlocked}s(R R R R RRR R!(((R RNs    cCsto t‚ntadS(s^Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.N(RRRR(((R R…s  (R t __author__t __email__t__all__t tracebackRt ExceptionRRRRRtobjectRRRRRR( RR$RRRR"R#RRRR((R t? s    3