Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -9,7 +9,7 @@ def init_async():
|
|
| 9 |
torch.classes.__path__ = [] # add this line to manually set it to empty.
|
| 10 |
|
| 11 |
|
| 12 |
-
def run_async_task(async_func, *
|
| 13 |
"""
|
| 14 |
Run an asynchronous function in a new event loop.
|
| 15 |
|
|
@@ -25,7 +25,9 @@ def run_async_task(async_func, *args):
|
|
| 25 |
|
| 26 |
try:
|
| 27 |
loop = asyncio.new_event_loop()
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
except:
|
| 30 |
# Close the existing loop if open
|
| 31 |
if loop is not None:
|
|
|
|
| 9 |
torch.classes.__path__ = [] # add this line to manually set it to empty.
|
| 10 |
|
| 11 |
|
| 12 |
+
def run_async_task(async_func, **kwargs):
|
| 13 |
"""
|
| 14 |
Run an asynchronous function in a new event loop.
|
| 15 |
|
|
|
|
| 25 |
|
| 26 |
try:
|
| 27 |
loop = asyncio.new_event_loop()
|
| 28 |
+
values = [val for val in kwargs.values()]
|
| 29 |
+
|
| 30 |
+
loop.run_until_complete(async_func(values))
|
| 31 |
except:
|
| 32 |
# Close the existing loop if open
|
| 33 |
if loop is not None:
|