Open stephanerey opened 3 months ago
When you're calling asyncio.run, it creates and runs default asyncio loop on the main thread.
You're later attempting to replace already running loop with a newly instantiated QAsync loop, inside of the initial loop, without stopping and closing it first.
Weird that this code worked in the first place, because it shouldn't have.
Normally, you'd need to instantiate qasync loop outside of asynchronous context, set it as the main loop, and then start the asynchronous task (with loop running via run_forever or run_until_complete).
thanks for your reply. I'm probably confusing and I'm sorry. I thought the asyncio.get_event_loop() was used in order to get the current running loop so I do not understand why I'm instantiating a new loop in my code. Next if one can't instantiate a new thread other than in the main thread how to you do to start a new thread that is triggered by an event from anywhere in the code other than the main thread ? Does it mean all the threads should be created and doing nothing until something unlock the code inside ?
The code below where I'm creating an async task "counter" from the MainUI class init function was working fine with version 0.24.0 but is not working anymore from 0.24.2. The task is never created while the loop is running. Creating the same task in the same loop from the main() function works fine with 0.24.0 up to lastest 0.27.1 (commented lines in the main() ) Is there something wrong in my task creation code ?