aboutsummaryrefslogtreecommitdiff
path: root/cryptech_muxd
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-05-03 11:21:46 -0400
committerRob Austein <sra@hactrn.net>2017-05-03 11:21:46 -0400
commitbbd9c119726bcfa7995a2f68633585a08a0bdc0f (patch)
treed661e5e64fbf93bb79eb4efbb225b0568613a8a3 /cryptech_muxd
parenta76a684fbd33c2b90a33e9c12e7536149630d6b5 (diff)
Tweak PySerial write_timeout setting.
Diffstat (limited to 'cryptech_muxd')
-rwxr-xr-xcryptech_muxd16
1 files changed, 15 insertions, 1 deletions
diff --git a/cryptech_muxd b/cryptech_muxd
index d28f758..d5de227 100755
--- a/cryptech_muxd
+++ b/cryptech_muxd
@@ -94,8 +94,22 @@ class SerialIOStream(tornado.iostream.BaseIOStream):
Implementation of a Tornado IOStream over a PySerial device.
"""
+ # In theory, we want zero (non-blocking mode) for both the read
+ # and write timeouts here so that PySerial will let Tornado handle
+ # all the select()/poll()/epoll()/kqueue() fun, delivering maximum
+ # throughput to all. In practice, this has always worked for the
+ # author, but another developer reports that on some (not all)
+ # platforms this fails consistently with Tornado reporting write
+ # timeout errors, presumably as the result of receiving an IOError
+ # or OSError exception from PySerial. For reasons we don't really
+ # understand, setting a PySerial write timeout on the order of
+ # 50-100 ms "solves" this problem. Again in theory, this will
+ # result in lower throughput if PySerial spends too much time
+ # blocking on a single serial device when Tornado could be doing
+ # something useful elsewhere, but such is life.
+
def __init__(self, device):
- self.serial = serial.Serial(device, 921600, timeout = 0, write_timeout = 0)
+ self.serial = serial.Serial(device, 921600, timeout = 0, write_timeout = 0.1)
self.serial_device = device
super(SerialIOStream, self).__init__()