Commit 3e49b61d authored by Guillaume Seguin's avatar Guillaume Seguin

Bring back SelectError on reads

parent 704740f5
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from serial import Serial, SerialException from serial import Serial, SerialException
from select import error as SelectError
from threading import Thread from threading import Thread
import time, getopt, sys import time, getopt, sys
import platform, os, traceback import platform, os, traceback
...@@ -166,6 +167,12 @@ class printcore(): ...@@ -166,6 +167,12 @@ class printcore():
except: pass except: pass
if self.loud: print "RECV: ", line.rstrip() if self.loud: print "RECV: ", line.rstrip()
return line return line
except SelectError, e:
if 'Bad file descriptor' in e.args[1]:
print "Can't read from printer (disconnected?)."
return None
else:
raise
except SerialException, e: except SerialException, e:
print "Can't read from printer (disconnected?)." print "Can't read from printer (disconnected?)."
return None return 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