CraftSpider / dpytest

A package that assists in writing tests for discord.py
MIT License
103 stars 24 forks source link

issue with event loop not completing on_error task #27

Closed bravosierra99 closed 3 years ago

bravosierra99 commented 4 years ago

so I'm running into an issue with runner.py!message (line 264). I don't think it's anything I've caused but I could be wrong. My command is properly throwing a BadArgument Error, which is getting dispatched to the "on_error" event as a task in the event_loop. However, by the time line 272 of runner.py finishes and it goes to line 274, the Task has NOT completed. I can see it in the list by doing asyncio.all_tasks(). This causes the error_queue.empty() call to be true, which should not be the case. So it appears there is some issue with making sure Tasks that are created during the execution of a command are actually completed.

bravosierra99 commented 4 years ago

ok so I just noticed that you are filtering on only "_run_event" coroutines, but I think we kinda need all the tasks from discord to finish as well?

bravosierra99 commented 4 years ago

learning as I go, but there definitely appears to be some sort of race condition. Sometimes my tests fail, sometimes they don't. But my test always raises the appropriate error, it just depends on if the Task "on_command_error" completes or not.