-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task was destroyed but it is pending! #7
Comments
I have created a test script which reproduces the error. Switch between Change
|
It’s a bug that there is no strong reference being held to the task here Probably other occurrences as well |
Looks like that bug exists upstream as well |
Probably the timings being different and not blocking the event loop is the reason it can now be garbage collected sooner |
The fix in aiolifx/aiolifx#70 could be adapted and reused if you are interested in doing a PR to fix this |
Should that fix also be applied to |
@bdraco , is my fix sufficient for you? |
Yes but serial_asyncio seems abandoned which is why this lib was created |
@bdraco, I don't think this was properly addressed. Stashing a reference to the task doesn't mean that it gets executed, it just prevents it from getting destroyed. In the example code, the task still hasn't been run when the program exits and the serial connection still hasn't actually been closed. The difference in behavior started with pyserial#82, which was merged but not released in Previously, I'd really like to see this issue reopened. |
We ran into this a moment ago. I think pushing |
Test out #16. I believe it should solve this issue. |
@rrooggiieerr I've spent some more time digging here and I think your test case should be amended: # Close the connection.
writer.close()
+ await writer.wait_closed()
|
@puddly, I think you are right |
@cottsay, thanks for diving into this. Your analysis looks very valid |
I've developed a hand full of HA integrations which connect over the serial port. Currently I'm in the process of migration the different libraries used by these integrations from synchronous pyserial to asynchronous communication.
First I migrated to
pyserial-asyncio
and after finding out aboutpyserial-asyncio-fast
I used that as a drop in replacement as this seems to be the recommended library to use.I'm currently working on my XY Screens projector screen integration. When running my unit tests using
pyserial-asyncio
everything goes fine, but when usingpyserial-asyncio-fast
I get the following error:The only thing different in the coded is I change
import serial_asyncio
toimport serial_asyncio_fast as serial_asyncio
The text was updated successfully, but these errors were encountered: