Commit 167470e6 authored by Duane Johnson's avatar Duane Johnson

Added a try/except block around readline so that disconnection does not yield a traceback.

parent 440a5ca5
#!/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