Commit e9c3bf44 by rfkelly0

ConnectionManagerFS: allow wait_for_connection to force waiting even if apparently connected

parent f001445d
...@@ -328,9 +328,11 @@ class ConnectionManagerFS(LazyFS): ...@@ -328,9 +328,11 @@ class ConnectionManagerFS(LazyFS):
self._connection_cond = threading.Condition() self._connection_cond = threading.Condition()
self._poll_sleeper = threading.Event() self._poll_sleeper = threading.Event()
def wait_for_connection(self,timeout=None): def wait_for_connection(self,timeout=None,force_wait=False):
self._connection_cond.acquire() self._connection_cond.acquire()
try: try:
if force_wait:
self.connected = False
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
...@@ -344,7 +346,7 @@ class ConnectionManagerFS(LazyFS): ...@@ -344,7 +346,7 @@ class ConnectionManagerFS(LazyFS):
def _poll_connection(self): def _poll_connection(self):
while not self.connected and not self.closed: while not self.connected and not self.closed:
try: try:
self.wrapped_fs.isdir("") self.wrapped_fs.getinfo("/")
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()
......
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