Skip to content

Commit

Permalink
LocalEngine: adds wait after full queue was checked
Browse files Browse the repository at this point in the history
  • Loading branch information
dthulke committed Apr 19, 2024
1 parent 6e8cfc8 commit 7f2747f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sisyphus/localengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def release_resources(self, rqmt, selected_devices):

@tools.default_handle_exception_interrupt_main_thread
def run(self):
next_task = None
checked_tasks_since_last_wait = 0
try:
while self.running.value:
self.check_finished_tasks()
Expand Down Expand Up @@ -229,7 +229,8 @@ def run(self):
running_tasks[name] = (process, next_task, selected_gpus)
else:
# Put next_task at end of queue and try to schedule the next one
if self.input_queue.empty():
checked_tasks_since_last_wait += 1
if checked_tasks_since_last_wait > self.input_queue.qsize():
# Wait if this is the only task in the queue
wait = True
self.input_queue.put(next_task)
Expand All @@ -238,6 +239,7 @@ def run(self):
# check only once per second for new jobs
# if no job has been started
time.sleep(1)
checked_tasks_since_last_wait = 0
except KeyboardInterrupt:
# KeyboardInterrupt is handled in manager
pass
Expand Down

0 comments on commit 7f2747f

Please sign in to comment.