[Cryptech-Commits] [sw/libhal] branch ksng updated: Tweak PySerial write_timeout setting.

git at cryptech.is git at cryptech.is
Wed May 3 15:26:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/libhal.

The following commit(s) were added to refs/heads/ksng by this push:
     new bbd9c11  Tweak PySerial write_timeout setting.
bbd9c11 is described below

commit bbd9c119726bcfa7995a2f68633585a08a0bdc0f
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Wed May 3 11:21:46 2017 -0400

    Tweak PySerial write_timeout setting.
---
 cryptech_muxd | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

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__()
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list