コード例 #1
0
 def __init__(self, wrapped_fs, poll_interval=None, connected=True):
     super(ConnectionManagerFS, self).__init__(wrapped_fs)
     if poll_interval is not None:
         self.poll_interval = poll_interval
     self._connection_cond = threading.Condition()
     self._poll_thread = None
     self._poll_sleeper = threading.Event()
     self.connected = connected
コード例 #2
0
 def __setstate__(self, state):
     super(ConnectionManagerFS, self).__setstate__(state)
     self._connection_cond = threading.Condition()
     self._poll_sleeper = threading.Event()
コード例 #3
0
    return wrapper


# During long-running operations, Dokan requires that the DokanResetTimeout
# function be called periodically to indicate the progress is still being
# made.  Unfortunately we don't have any facility for the underlying FS
# to make these calls for us, so we have to hack around it.
#
# The idea is to use a single background thread to monitor all active Dokan
# method calls, resetting the timeout until they have completed.  Note that
# this completely undermines the point of DokanResetTimeout as it's now
# possible for a deadlock to hang the entire filesystem.

_TIMEOUT_PROTECT_THREAD = None
_TIMEOUT_PROTECT_LOCK = threading.Lock()
_TIMEOUT_PROTECT_COND = threading.Condition(_TIMEOUT_PROTECT_LOCK)
_TIMEOUT_PROTECT_QUEUE = deque()
_TIMEOUT_PROTECT_WAIT_TIME = 4 * 60
_TIMEOUT_PROTECT_RESET_TIME = 5 * 60 * 1000


def _start_timeout_protect_thread():
    """Start the background thread used to protect dokan from timeouts.

    This function starts the background thread that monitors calls into the
    dokan API and resets their timeouts.  It's safe to call this more than
    once, only a single thread will be started.
    """
    global _TIMEOUT_PROTECT_THREAD
    with _TIMEOUT_PROTECT_LOCK:
        if _TIMEOUT_PROTECT_THREAD is None: