From e0501640dc083a596945e1f51c8c6422f539b9de Mon Sep 17 00:00:00 2001
From: Chris Hines <chris.hines@monash.edu>
Date: Thu, 21 May 2020 15:37:20 +1000
Subject: [PATCH] try again to fix TWS

---
 TWS/twsproxy/__init__.py | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/TWS/twsproxy/__init__.py b/TWS/twsproxy/__init__.py
index ad4ded3..eb1f09e 100644
--- a/TWS/twsproxy/__init__.py
+++ b/TWS/twsproxy/__init__.py
@@ -183,12 +183,9 @@ class TWSProxy(threading.Thread):
         logger = logging.getLogger()
         closed = False
         name = threading.current_thread().name
-        failcount=0
-        failthresh = 10
-        while not closed and failcount < failthresh:
+        while not closed:
             r,w,e = select.select([src],[],[],TWSProxy.TIMEOUT)
             if len(r) > 0:
-                failcount=0
                 buff = None
                 msglength = -1
                 try:
@@ -196,26 +193,23 @@ class TWSProxy(threading.Thread):
                     if buff is None:
                         continue
                 except ConnectionResetError as e:
-                    close = True
+                    closed = True
                     continue
                 except Exception as e:
                     import traceback
                     logger.error(traceback.format_exc())
-#                    closed = True
-                    continue
+                    closed = True
                 msglength = len(buff)
                 if msglength > 0:
                     TWSProxy.reliablesend(dest,buff,msglength)
                 if msglength == 0:
+                    #dest.send(buff)
                     dest.shutdown(shuttype)
                     initshutdown.set()
                     closed = True
-            else: 
-                failcount=failcount+1
 
-        if failcount > failthresh:
-            dest.shutdown(shuttype)
-            initshutdown.set()
+        dest.shutdown(shuttype)
+        initshutdown.set()
 
 def main():
     from . import server
-- 
GitLab