Commit f2e350a7 by rfkelly0

more pessimistic locking for ConnectionManagerFS

parent 359377ac
...@@ -195,12 +195,14 @@ class ConnectionManagerFS(WrapFS): ...@@ -195,12 +195,14 @@ class ConnectionManagerFS(WrapFS):
def wait_for_connection(self,timeout=None): def wait_for_connection(self,timeout=None):
self._connection_cond.acquire() self._connection_cond.acquire()
try:
if not self.connected: if not self.connected:
if not self._poll_thread: if not self._poll_thread:
target = self._poll_connection target = self._poll_connection
self._poll_thread=threading.Thread(target=target) self._poll_thread = threading.Thread(target=target)
self._poll_thread.start() self._poll_thread.start()
self._connection_cond.wait(timeout) self._connection_cond.wait(timeout)
finally:
self._connection_cond.release() self._connection_cond.release()
def _poll_connection(self): def _poll_connection(self):
...@@ -210,15 +212,16 @@ class ConnectionManagerFS(WrapFS): ...@@ -210,15 +212,16 @@ class ConnectionManagerFS(WrapFS):
except RemoteConnectionError: except RemoteConnectionError:
self._poll_sleeper.wait(self.poll_interval) self._poll_sleeper.wait(self.poll_interval)
self._poll_sleeper.clear() self._poll_sleeper.clear()
continue
except FSError: except FSError:
break break
else: else:
break break
self._connection_cond.acquire() self._connection_cond.acquire()
try:
self.connected = True self.connected = True
self._poll_thread = None self._poll_thread = None
self._connection_cond.notifyAll() self._connection_cond.notifyAll()
finally:
self._connection_cond.release() self._connection_cond.release()
def close(self): def close(self):
......
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