Revision bba69414 lib/workerpool.py

b/lib/workerpool.py
133 133
    """
134 134
    return (self._current_task is not None)
135 135

  
136
  def _GetCurrentOrderAndTaskId(self):
137
    """Returns the order and task ID of the current task.
138

  
139
    Should only be called from within L{RunTask}.
140

  
141
    """
142
    self.pool._lock.acquire()
143
    try:
144
      assert self._HasRunningTaskUnlocked()
145

  
146
      (_, order_id, task_id, _) = self._current_task
147

  
148
      return (order_id, task_id)
149
    finally:
150
      self.pool._lock.release()
151

  
136 152
  def run(self):
137 153
    """Main thread function.
138 154

  
......
202 218
          if defer:
203 219
            assert self._current_task
204 220
            # Schedule again for later run
205
            (_, _, _, args) = self._current_task
206
            pool._AddTaskUnlocked(args, defer.priority, None)
221
            (_, _, task_id, args) = self._current_task
222
            pool._AddTaskUnlocked(args, defer.priority, task_id)
207 223

  
208 224
          if self._current_task:
209 225
            self._current_task = None
......
299 315
    """
300 316
    assert isinstance(args, (tuple, list)), "Arguments must be a sequence"
301 317
    assert isinstance(priority, (int, long)), "Priority must be numeric"
318
    assert task_id is None or isinstance(task_id, (int, long)), \
319
      "Task ID must be numeric or None"
302 320

  
303 321
    task = [priority, self._counter.next(), task_id, args]
304 322

  

Also available in: Unified diff