I am in the middle of having two of my bots interfacing with each other via a ZMQ server, unfortunately that also requires a second loop for the receiver, so i started looking around the web for solutions and came up with this:
async def interfaceSocket():
while True:
message = socket.recv()
time.sleep(1)
socket.send(b"World")
await asyncio.sleep(3)
@client.event
async def on_ready():
print('logged in as:')
print(client.user.name)
client.loop.create_task(interfaceSocket())
client.run(TOKEN)
I basically added the interfaceSocket function to the event loop as a task as another while loop so i can constantly check the socket receiver while also checking the on_message listener from the discord bot itself but for some reason, the loop still interrupts the main event loop. Why is this?