summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-14 00:12:31 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-14 00:12:31 +0100
commita0fc1dd7dba89dccdb730f8ea0259e4ac9ba7e08 (patch)
treee747251513b9ffd24c702696e406b4837ca172f0
parent[Plugin] Some fixes by rlindner81 (diff)
downloadpyload-a0fc1dd7dba89dccdb730f8ea0259e4ac9ba7e08.tar.xz
[Plugin] Fix wait routine (thx rlindner81)
-rw-r--r--module/plugins/Plugin.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 120dc9a6e..4dadb67b4 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -286,6 +286,12 @@ class Plugin(Base):
return True, 10
+ def setReconnect(self, reconnect):
+ reconnect = bool(reconnect)
+ self.logDebug("Set wantReconnect to: %s (previous: %s)" % (reconnect, self.wantReconnect))
+ self.wantReconnect = reconnect
+
+
def setWait(self, seconds, reconnect=None):
"""Set a specific wait time later used with `wait`
@@ -301,16 +307,19 @@ class Plugin(Base):
self.pyfile.waitUntil = wait_until
if reconnect is not None:
- self.logDebug("Set wantReconnect to: %s (previous: %s)" % (reconnect, self.wantReconnect))
- self.wantReconnect = reconnect
+ self.setReconnect(reconnect)
- def wait(self, seconds=0, reconnect=None):
+ def wait(self, seconds=None, reconnect=None):
""" waits the time previously set """
pyfile = self.pyfile
- self.setWait(seconds, reconnect)
+ if seconds is not None:
+ self.setWait(seconds)
+
+ if reconnect is not None:
+ self.setReconnect(reconnect)
self.waiting = True
@@ -321,10 +330,14 @@ class Plugin(Base):
"WAITUNTIL: %f" % pyfile.waitUntil,
"RECONNECT: %s" % self.wantReconnect)
- if not account:
+ if self.account:
self.logDebug("Ignore reconnection due account logged")
while pyfile.waitUntil > time():
+ if pyfile.abort:
+ self.abort()
+ else:
+ while pyfile.waitUntil > time():
self.thread.m.reconnecting.wait(2)
if pyfile.abort:
@@ -334,10 +347,6 @@ class Plugin(Base):
self.waiting = False
self.wantReconnect = False
raise Reconnect
- else:
- while pyfile.waitUntil > time():
- if pyfile.abort:
- self.abort()
self.waiting = False