Closed csboling closed 5 years ago
Yeah, this is the part that's causing the exception, but I'm not sure the .cancel()
call makes sense here. Shouldn't the printer
keep running so we keep reading from the serial port?
If the prompt-toolkit Application already exited then there's nowhere to show it though, right? Not sure how else to end the background task since read() faulting will just attempt to reconnect.
This is great. All seems to be working well & fixes the error on Windows (didn't check osx yet).
To be clear, I had no idea what i was doing with the asyncio
stuff. I just hacked different examples together until it worked. read: that .cancel
call was copied directly from an example and i have no idea what it does.
If the prompt-toolkit Application already exited then there's nowhere to show it though, right? Not sure how else to end the background task since read() faulting will just attempt to reconnect.
ah, yeah, you're right, I'm not sure this is the correct way of doing things (ie run run_until_complete
followed by a cancel
for something else), but it seems to work fine.
Just doesn't
run_until_complete
the background task after it has been cancelled, since I think this is all the CancelledError means. @simonvanderveldt this feels almost too easy to be the "right" way to fix #12? Works on Windows and OSX, no hanging shell, no lingering Python processes.The
if is_connected
check is just to prevent a traceback if you quit out of druid without having connected a device, because in that case thecrow
global isNone
.