I have a discord.py project that has a main.py file that runs client.run(discord_token) and also has two other async functions called get_mongo() and dump_mongo(). I have another file called /Web_Interaction/loopty_loop.py that needs to import these two functions. I call these two functions inside of a looped function in loopty_loop.py.
from discord.ext import tasksimport asyncio@tasks.loop(time=times)async def curate(client, channel, mongo_client): print('curating...') from main import get_mongo, dump_mongo ...And I'm getting the following error:
Traceback (most recent call last): File "/home/andy/.local/lib/python3.12/site-packages/discord/client.py", line 441, in _run_event await coro(*args, **kwargs) File "/home/andy/CE-Assistant/main.py", line 1433, in on_ready await master_loop.start(client, mongo_client) File "/home/andy/.local/lib/python3.12/site-packages/discord/ext/tasks/__init__.py", line 264, in _loop raise exc File "/home/andy/.local/lib/python3.12/site-packages/discord/ext/tasks/__init__.py", line 239, in _loop await self.coro(*args, **kwargs) File "/home/andy/CE-Assistant/Web_Interaction/loopty_loop.py", line 102, in master_loop await curate(correct_channel, mongo_client) File "/home/andy/CE-Assistant/Web_Interaction/loopty_loop.py", line 119, in curate from main import get_mongo, dump_mongo File "/home/andy/CE-Assistant/main.py", line 1437, in <module> client.run(discord_token) File "/home/andy/.local/lib/python3.12/site-packages/discord/client.py", line 860, in run asyncio.run(runner()) File "/usr/local/lib/python3.12/asyncio/runners.py", line 190, in run raise RuntimeError(RuntimeError: asyncio.run() cannot be called from a running event loopIf I move from main import get_mongo, dump_mongo to outside of my function, I get a circular import error. Anyone have any ideas?