From 9b68c2f7be09073c6e2f4e3c50c5c88a7e72105e Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Fri, 28 Apr 2017 15:29:03 -0400 Subject: [PATCH] sync up the changes between the py27 and py34 versions --- py27/bacpypes/tcp.py | 16 ++++++---------- py34/bacpypes/tcp.py | 8 ++++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/py27/bacpypes/tcp.py b/py27/bacpypes/tcp.py index aa1134b..031a220 100644 --- a/py27/bacpypes/tcp.py +++ b/py27/bacpypes/tcp.py @@ -232,7 +232,10 @@ class TCPClient(asyncore.dispatcher): if _debug: TCPClient._debug("handle_close") # close the socket - self.socket.close() + self.close() + + # no longer connected + self.connected = False # make sure other routines know the socket is closed self.socket = None @@ -318,14 +321,6 @@ class TCPClientActor(TCPClient): def handle_close(self): if _debug: TCPClientActor._debug("handle_close") -# if _debug: -# stack_information = list(traceback.extract_stack()) -# stack_information.reverse() -# stack_information = '\n'.join(" %-15s%s:%s" % ( -# fn, filename.split('/')[-1], lineno) for filename, lineno, fn, _ in stack_information -# ) -# TCPClientActor._debug(" - stack_information: %s", stack_information) - # if there's a flush task, cancel it if self.flush_task: self.flush_task.suspend_task() @@ -447,6 +442,7 @@ class TCPClientDirector(Server, ServiceAccessPoint, DebugContents): """Remove an actor when the socket is closed.""" if _debug: TCPClientDirector._debug("del_actor %r", actor) + # delete the client del self.clients[actor.peer] # tell the ASE the client has gone away @@ -551,7 +547,7 @@ class TCPServer(asyncore.dispatcher): if (err.args[0] == 111): if _debug: TCPServer._debug(" - connection to %r refused", self.peer) else: - if _debug: TCPServer._debug(" - recv socket error: %s", err) + if _debug: TCPServer._debug(" - recv socket error: %r", err) # pass along to a handler self.handle_error(err) diff --git a/py34/bacpypes/tcp.py b/py34/bacpypes/tcp.py index e8caf0c..97be481 100755 --- a/py34/bacpypes/tcp.py +++ b/py34/bacpypes/tcp.py @@ -232,7 +232,10 @@ class TCPClient(asyncore.dispatcher): if _debug: TCPClient._debug("handle_close") # close the socket - self.socket.close() + self.close() + + # no longer connected + self.connected = False # make sure other routines know the socket is closed self.socket = None @@ -439,6 +442,7 @@ class TCPClientDirector(Server, ServiceAccessPoint, DebugContents): """Remove an actor when the socket is closed.""" if _debug: TCPClientDirector._debug("del_actor %r", actor) + # delete the client del self.clients[actor.peer] # tell the ASE the client has gone away @@ -543,7 +547,7 @@ class TCPServer(asyncore.dispatcher): if (err.args[0] == 111): if _debug: TCPServer._debug(" - connection to %r refused", self.peer) else: - if _debug: TCPServer._debug(" - recv socket error: %s", err) + if _debug: TCPServer._debug(" - recv socket error: %r", err) # pass along to a handler self.handle_error(err)