locking.py (pymol-v1.8.6.0.tar.bz2) | : | locking.py (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 56 | skipping to change at line 56 | |||
_self.lock_glut(_self) | _self.lock_glut(_self) | |||
_self.lock(_self) | _self.lock(_self) | |||
finally: | finally: | |||
_self.unlock_glut(_self) | _self.unlock_glut(_self) | |||
class LockCM(object): | class LockCM(object): | |||
''' | ''' | |||
API lock context manager | API lock context manager | |||
''' | ''' | |||
def __init__(self, _self=cmd): | def __init__(self, _self=cmd): | |||
self.cmd = _self | self.cmd = _self._weakrefproxy | |||
def __enter__(self): | def __enter__(self): | |||
lock(self.cmd) | lock(self.cmd) | |||
def __exit__(self, type, value, traceback): | def __exit__(self, type, value, traceback): | |||
unlock(None, self.cmd) | unlock(None, self.cmd) | |||
def lock(_self=cmd): # INTERNAL -- API lock | def lock(_self=cmd): # INTERNAL -- API lock | |||
# print " lock: acquiring as 0x%x"%thread.get_ident(),(thread.get_ident() = = pymol.glutThread) | # print " lock: acquiring as 0x%x"%thread.get_ident(),(thread.get_ident() = = pymol.glutThread) | |||
if not _self.lock_api.acquire(0): | if not _self.lock_api.acquire(0): | |||
w = 0.0001 | w = 0.0001 | |||
while 1: | while 1: | |||
skipping to change at line 107 | skipping to change at line 107 | |||
if not _self.reaper.isAlive(): | if not _self.reaper.isAlive(): | |||
if pymol.invocation.options.no_gui: | if pymol.invocation.options.no_gui: | |||
_cmd.quit(_self._COb) # TO FIX | _cmd.quit(_self._COb) # TO FIX | |||
else: | else: | |||
_self.reaper = None | _self.reaper = None | |||
except: | except: | |||
pass | pass | |||
_self.lock_api.release() | _self.lock_api.release() | |||
# print "lock: released by 0x%x (glut)"%thread.get_ident() | # print "lock: released by 0x%x (glut)"%thread.get_ident() | |||
if _self.lock_api_allow_flush: | if _self.lock_api_allow_flush: | |||
if result==None: # don't flush if we have an incipient error (negati ve input) | if result is None: # don't flush if we have an incipient error (nega tive input) | |||
_cmd.flush_now(_self._COb) | _cmd.flush_now(_self._COb) | |||
elif _self.is_ok(result): | elif _self.is_ok(result): | |||
_cmd.flush_now(_self._COb) | _cmd.flush_now(_self._COb) | |||
else: | else: | |||
# print "lock: released by 0x%x (not glut), waiting queue"%thread.ge t_ident() | # print "lock: released by 0x%x (not glut), waiting queue"%thread.ge t_ident() | |||
_self.lock_api.release() | _self.lock_api.release() | |||
if _cmd.wait_queue(_self._COb): # commands waiting to be executed? | if _cmd.wait_queue(_self._COb): # commands waiting to be executed? | |||
e = threading.Event() # abdicate control for a 100 usec for quick ta sks | e = threading.Event() # abdicate control for a 100 usec for quick ta sks | |||
e.wait(0.0001) | e.wait(0.0001) | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |