Commit edeb4339 authored by kliment's avatar kliment

Merge pull request #98 from canadaduane/friendlydisconnect

Catch exception so that disconnection does not give a traceback
parents d704bba3 167470e6
#!/usr/bin/env python #!/usr/bin/env python
from serial import Serial from serial import Serial
from threading import Thread from threading import Thread
from select import error as SelectError
import time import time
import sys import sys
...@@ -76,7 +77,15 @@ class printcore(): ...@@ -76,7 +77,15 @@ class printcore():
while(True): while(True):
if(not self.printer or not self.printer.isOpen): if(not self.printer or not self.printer.isOpen):
break break
line=self.printer.readline() try:
line=self.printer.readline()
except SelectError, e:
if 'Bad file descriptor' in e.args[1]:
print "Can't read from printer (disconnected?)."
break
else:
raise
if(len(line)>1): if(len(line)>1):
self.log+=[line] self.log+=[line]
if self.recvcb is not None: if self.recvcb is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment