pseudotheos
commited on
Commit
•
bddb72f
1
Parent(s):
e142abe
Update app.py
Browse files
app.py
CHANGED
@@ -41,6 +41,9 @@ stream_handler.setFormatter(formatter)
|
|
41 |
logger.addHandler(file_handler)
|
42 |
logger.addHandler(stream_handler)
|
43 |
|
|
|
|
|
|
|
44 |
class ImageGenerationQueue:
|
45 |
def __init__(self):
|
46 |
self.queue = asyncio.Queue()
|
@@ -327,10 +330,12 @@ async def generate_image(
|
|
327 |
return "Failed to generate image"
|
328 |
|
329 |
try:
|
330 |
-
|
331 |
-
|
|
|
332 |
|
333 |
-
|
|
|
334 |
position_in_queue = queue_manager.queue.qsize()
|
335 |
|
336 |
# Total queue size is still async
|
|
|
41 |
logger.addHandler(file_handler)
|
42 |
logger.addHandler(stream_handler)
|
43 |
|
44 |
+
next_id = 0
|
45 |
+
next_id_lock = threading.Lock()
|
46 |
+
|
47 |
class ImageGenerationQueue:
|
48 |
def __init__(self):
|
49 |
self.queue = asyncio.Queue()
|
|
|
330 |
return "Failed to generate image"
|
331 |
|
332 |
try:
|
333 |
+
with next_id_lock:
|
334 |
+
id = next_id
|
335 |
+
next_id += 1
|
336 |
|
337 |
+
background_tasks.add_task(lambda _: generate_image_task(id))
|
338 |
+
# queue_manager.add_task(lambda _: generate_image_task(id))
|
339 |
position_in_queue = queue_manager.queue.qsize()
|
340 |
|
341 |
# Total queue size is still async
|