Permalink
Browse files

Add to connection.close a check to avoid double closing.

  • Loading branch information...
1 parent bd6fb84 commit 4572d484fcef13fb3b6ecf5601e0d73d079a2a64 @deavid committed May 23, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 bjsonrpc/connection.py
View
@@ -204,6 +204,7 @@ def __init__(self, sck, address = None, handler_factory = None):
self._sck = sck
self._address = address
self._handler = handler_factory
+ self.connection_status = "open"
if self._handler:
self.handler = self._handler(self)
@@ -624,7 +625,7 @@ def close(self):
"""
Close the connection and the socket.
"""
-
+ if self.connection_status == "closed": return
item = {
'abort' : True,
'event' : threading.Event()
@@ -644,6 +645,7 @@ def close(self):
except socket.error:
pass
self._sck.close()
+ self.connection_status = "closed"
def write_line(self, data):
"""

0 comments on commit 4572d48

Please sign in to comment.