Fix hang on CTRL+C
Closed this issue · 0 comments
CoatedMoose commented
Attempting to terminate execution of the base station usually causes the terminal to hang on linux. There is a similar (probably related issue) on windows.
The problem is that the code reading the xbee (python-xbee library) reads in a blocking synchronous manner an another thread. There is no way for that thread to know about the SIGINT, so unless CTRL+C.
Workarounds:
- there is a (poorly written) script to kill any python base stations connected (for linux), it makes use of killall
- unplugging the xbee causes the rogue thread to crash, and allows for a "clean" exit
There are a few options to fix:
- modify python-xbee to make async to the serial port (possibly using twisted's serial module)
- re-implement python xbee using twisted
- use this wrapper that I just found (this is the preferred solution currently