From 5d4d0bdd01317bd158329afab39439fea89bdc35 Mon Sep 17 00:00:00 2001 From: cliechti Date: Sat, 13 Nov 2004 03:27:39 +0000 Subject: - [Patch 1043436] Fix for [Bug 1043420] (OSError: EAGAIN) --- pyserial/serial/serialposix.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py index 9e17068..22a0336 100644 --- a/pyserial/serial/serialposix.py +++ b/pyserial/serial/serialposix.py @@ -13,7 +13,7 @@ import sys, os, fcntl, termios, struct, select from serialutil import * -VERSION = "$Revision: 1.23 $".split()[1] #extract CVS version +VERSION = "$Revision: 1.24 $".split()[1] #extract CVS version #Do check the Python version as some constants have moved. if (sys.hexversion < 0x020100f0): @@ -281,17 +281,21 @@ class Serial(SerialBase): t = len(data) d = data while t > 0: - if self._writeTimeout is not None and self._writeTimeout > 0: - _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) - if not ready: - raise writeTimeoutError - n = os.write(self.fd, d) - if self._writeTimeout is not None and self._writeTimeout > 0: - _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) - if not ready: - raise writeTimeoutError - d = d[n:] - t = t - n + try: + if self._writeTimeout is not None and self._writeTimeout > 0: + _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) + if not ready: + raise writeTimeoutError + n = os.write(self.fd, d) + if self._writeTimeout is not None and self._writeTimeout > 0: + _,ready,_ = select.select([],[self.fd],[], self._writeTimeout) + if not ready: + raise writeTimeoutError + d = d[n:] + t = t - n + except OSError,v: + if v.errno != errno.EAGAIN: + raise def flush(self): """Flush of file like objects. In this case, wait until all data -- cgit v1.2.1