Save last lock time

This commit is contained in:
shortcutme 2019-12-18 16:42:47 +01:00
parent 845b50915d
commit 7af8d1cd93
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -72,8 +72,10 @@ class Lock:
self.lock = gevent._threading.Lock() self.lock = gevent._threading.Lock()
self.locked = self.lock.locked self.locked = self.lock.locked
self.release = self.lock.release self.release = self.lock.release
self.time_lock = 0
def acquire(self, *args, **kwargs): def acquire(self, *args, **kwargs):
self.time_lock = time.time()
if self.locked() and isMainThread(): if self.locked() and isMainThread():
# Start in new thread to avoid blocking gevent loop # Start in new thread to avoid blocking gevent loop
return lock_pool.apply(self.lock.acquire, args, kwargs) return lock_pool.apply(self.lock.acquire, args, kwargs)