mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-20 13:13:16 +00:00
Added functions to use asyncio
This commit is contained in:
parent
52d77cacc1
commit
adf1e23559
@ -26,6 +26,27 @@ import base64
|
||||
import importlib
|
||||
import yaml
|
||||
|
||||
import asyncio
|
||||
|
||||
def run_async(func):
|
||||
"""
|
||||
run_async(func) -> None
|
||||
|
||||
Utility function to run async functions in sync environment. Takes an async function as input and runs it within an async context.
|
||||
|
||||
Parameters:
|
||||
func (function): The async function to run.
|
||||
|
||||
Returns:
|
||||
None: Nothing is returned since the function is meant to perform side effects.
|
||||
"""
|
||||
|
||||
async def wrapper(*args, **kwargs):
|
||||
return await func(*args, **kwargs)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(wrapper())
|
||||
|
||||
|
||||
def terminate_thread(thread):
|
||||
if thread:
|
||||
|
Loading…
Reference in New Issue
Block a user