I’m working on a simple serial transfer program with python 2.7 serial on win7. On my first effort it locked up and I had to terminate it manually. This resulted in the port being inaccessible and needing a re-boot to recover.
I’ll be more careful, of course, but is there any way to be bullet-proof sure that the port gets closed?
When invoking your serial device, you might want to use timeout= argument in the invocation.
I’ve been in trouble with the same case, and ended to use timeout + a construction to ensure the port is closed:
Check also the atexit module in case you’re halting the code in another way than control+c