def tryLock(self, timeout=None, id=None):
""" Try to lock the mutex.
@param timeout int: give up after this many milliseconds
@param id: debug id
@return bool: whether locking succeeded
"""
if timeout is None:
locked = QtCore.QMutex.tryLock(self)
else:
locked = QtCore.QMutex.tryLock(self, timeout)
if self.debug and locked:
self.l.lock()
try:
if id is None:
self.tb.append(''.join(traceback.format_stack()[:-1]))
else:
self.tb.append(" " + str(id))
#print 'trylock', self, len(self.tb)
finally:
self.l.unlock()
return locked
评论列表
文章目录