Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,21 +69,12 @@ def process_prompt(sentence_mapping, character_dict, selected_style):
|
|
69 |
print(f"Sentence Mapping: {sentence_mapping}")
|
70 |
print(f"Character Dict: {character_dict}")
|
71 |
print(f"Selected Style: {selected_style}")
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
cmpt_return = asyncio.run_coroutine_threadsafe(coroutine, loop).result()
|
79 |
-
else:
|
80 |
-
loop = asyncio.new_event_loop()
|
81 |
-
asyncio.set_event_loop(loop)
|
82 |
-
print("Created new event loop.")
|
83 |
-
cmpt_return = loop.run_until_complete(queue_api_calls(sentence_mapping, character_dict, selected_style))
|
84 |
-
except RuntimeError as e:
|
85 |
-
print(f"Runtime error in event loop: {e}")
|
86 |
-
cmpt_return = {}
|
87 |
|
88 |
print("Prompt processing complete. Generated images: ", cmpt_return)
|
89 |
return cmpt_return
|
|
|
69 |
print(f"Sentence Mapping: {sentence_mapping}")
|
70 |
print(f"Character Dict: {character_dict}")
|
71 |
print(f"Selected Style: {selected_style}")
|
72 |
+
|
73 |
+
# Ensure we are in the right event loop context
|
74 |
+
loop = asyncio.new_event_loop()
|
75 |
+
asyncio.set_event_loop(loop)
|
76 |
+
cmpt_return = loop.run_until_complete(queue_api_calls(sentence_mapping, character_dict, selected_style))
|
77 |
+
loop.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
print("Prompt processing complete. Generated images: ", cmpt_return)
|
80 |
return cmpt_return
|