Skip to content
Snippets Groups Projects
Commit e3016c4d authored by Ramin Yaghoubzadeh Torky's avatar Ramin Yaghoubzadeh Torky
Browse files

py: added import time

parent 1885b618
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ import threading ...@@ -38,6 +38,7 @@ import threading
import uuid import uuid
import collections import collections
import copy import copy
import time
import rsb import rsb
import rsb.converter import rsb.converter
...@@ -258,15 +259,15 @@ class Payload(dict): ...@@ -258,15 +259,15 @@ class Payload(dict):
def _wait_batch_update_lock(self, timeout): def _wait_batch_update_lock(self, timeout):
# wait lock with time-out http://stackoverflow.com/a/8393033 # wait lock with time-out http://stackoverflow.com/a/8393033
with self._batch_update_cond: with self._batch_update_cond:
current_time = start_time = time.time() current_time = start_time = time.time()
while current_time < start_time + timeout: while current_time < start_time + timeout:
if self._batch_update_lock.acquire(False): if self._batch_update_lock.acquire(False):
return True return True
else: else:
self._batch_update_cond.wait(timeout - current_time + start_time) self._batch_update_cond.wait(timeout - current_time + start_time)
current_time = time.time() current_time = time.time()
raise IUPayloadLockTimeoutError(self.iu) raise IUPayloadLockTimeoutError(self.iu)
class IUInterface(object): #{{{ class IUInterface(object): #{{{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment