Example #1
0
 def __init__(self, maxsize=0):
     self.maxsize = maxsize
     self._init(maxsize)
     # mutex must be held whenever the queue is mutating.  All methods
     # that acquire mutex must release it before returning.  mutex
     # is shared between the three conditions, so acquiring and
     # releasing the conditions also acquires and releases mutex.
     self.mutex = Lock()
     # Notify not_empty whenever an item is added to the queue; a
     # task waiting to get is notified then.
     self.not_empty = Condition(self.mutex)
     # Notify not_full whenever an item is removed from the queue;
     # a task waiting to put is notified then.
     self.not_full = Condition(self.mutex)
     # Notify all_tasks_done whenever the number of unfinished tasks
     # drops to zero; task waiting to join() is notified to resume
     self.all_tasks_done = Condition(self.mutex)
     self.unfinished_tasks = 0
Example #2
0
 def __init__(self):
     self._lock = Lock()
     self._cond = Condition(Lock())
     self._locked = False
     self._used = False
     self._exc = self._value = Null
Example #3
0
 def __init__(self):
     self._cond = Condition(Lock())
     self._flag = False
Example #4
0
 def __init__(self):
     self._send_lock = Lock()
     self._recv_lock = Lock()
     self._new_data = Event()
     self._recv_data = Event()
     self._data = None
Example #5
0
 def __init__(self, max_workers):
     self._max_workers = max_workers
     self._tasks = set()
     self._work_queue = Queue()
     self._shutdown = False
     self._shutdown_lock = Lock()
Example #6
0
 def __init__(self):
     super(_AsCompletedWaiter, self).__init__()
     self.lock = Lock()
Example #7
0
 def __init__(self, num_pending_calls, stop_on_exception):
     self.num_pending_calls = num_pending_calls
     self.stop_on_exception = stop_on_exception
     self.lock = Lock()
     super(_AllCompletedWaiter, self).__init__()