You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
myvenv/lib/python3.10/site-packages/bqskit/utils/cachedclass.py:45: RuntimeWarning: coroutine 'RuntimeTask.run' was never awaited
hash_a = all(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
The line hash_a = all( is a seemingly random line of code each time. Note that the warnings don't show up every time; but they seem to show up more frequently when my CPU is under heavy load.
It seems to be related to get_runtime().cancel(my_future) because if I replace that line with await my_future I no longer see the warnings (but the code takes undersireably longer obviously).
The text was updated successfully, but these errors were encountered:
So I found the issue. You are supposed to close() coroutines if you aren't going to await them. (It's also safe to close() a coroutine after it has been awaited). Neither happens when a task gets cancelled currently.
The easier way is to simply implement __del__ for RuntimeTask which will close its coroutine.
The more explicit way would be to go close() all relevant coroutines when cancel gets called.
The 1st approach is a lot simpler. I'm pretty sure the warning happens when the unused coroutine gets garbage collected, so this approach is just letting python know it was ok for that coroutine to go unused.
The 2nd approach is a lot more work to implement, but it has a benfit in that if there is some future bug where a RuntimeTask falls through the cracks when it wasn't supposed to be cancelled, the warning might pop up to let you know. The 1st approach will make it so any time a RuntimeTask is never executed for any reason, the warning will not appear.
I have some code of the form:
I get warning messages of the form:
The line
hash_a = all(
is a seemingly random line of code each time. Note that the warnings don't show up every time; but they seem to show up more frequently when my CPU is under heavy load.It seems to be related to
get_runtime().cancel(my_future)
because if I replace that line withawait my_future
I no longer see the warnings (but the code takes undersireably longer obviously).The text was updated successfully, but these errors were encountered: