1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 23:14:49 +08:00

Do a garbage collect after the interval even if nothing is running.

This commit is contained in:
comfyanonymous
2023-11-30 15:22:32 -05:00
parent 7f469203b7
commit 6b769bca01
2 changed files with 33 additions and 18 deletions

View File

@@ -700,10 +700,12 @@ class PromptQueue:
self.server.queue_updated()
self.not_empty.notify()
def get(self):
def get(self, timeout=None):
with self.not_empty:
while len(self.queue) == 0:
self.not_empty.wait()
self.not_empty.wait(timeout=timeout)
if timeout is not None and len(self.queue) == 0:
return None
item = heapq.heappop(self.queue)
i = self.task_counter
self.currently_running[i] = copy.deepcopy(item)