Commit e56f46e7 authored by Jeremy Hylton's avatar Jeremy Hylton

Add __closed attribute to asyncRPC object.

__init__(): __closed = 0
connect(): In connecting thread, don't continue if __closed is true.
close(): __closed = 1
parent 30e6b67a
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"""Simple rpc mechanisms """Simple rpc mechanisms
""" """
__version__ = "$Revision: 1.16 $"[11:-2] __version__ = "$Revision: 1.17 $"[11:-2]
from cPickle import loads from cPickle import loads
import cPickle import cPickle
...@@ -117,6 +117,7 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -117,6 +117,7 @@ class asyncRPC(SizedMessageAsyncConnection):
self._outOfBand=outOfBand self._outOfBand=outOfBand
self._tmin, self._tmax = tmin, tmax self._tmin, self._tmax = tmin, tmax
self._debug=debug self._debug=debug
self.__closed = 0
l=allocate_lock() # Response lock used to wait for call results l=allocate_lock() # Response lock used to wait for call results
self.__la=l.acquire self.__la=l.acquire
...@@ -132,7 +133,7 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -132,7 +133,7 @@ class asyncRPC(SizedMessageAsyncConnection):
t=self._tmin t=self._tmin
connection = self._connection connection = self._connection
debug=self._debug debug=self._debug
while 1: while self.__closed == 0:
if log_type: LOG(log_type, INFO, if log_type: LOG(log_type, INFO,
'Trying to connect to server: %s' % `connection`) 'Trying to connect to server: %s' % `connection`)
try: try:
...@@ -292,5 +293,6 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -292,5 +293,6 @@ class asyncRPC(SizedMessageAsyncConnection):
asyncRPC.inheritedAttribute('close')(self) asyncRPC.inheritedAttribute('close')(self)
self.aq_parent.notifyDisconnected(self) self.aq_parent.notifyDisconnected(self)
self.__r='E'+dump(sys.exc_info()[:2], 1) self.__r='E'+dump(sys.exc_info()[:2], 1)
self.__closed = 1
try: self.__lr() try: self.__lr()
except: pass except: pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment