summaryrefslogtreecommitdiffstats
path: root/module/remote/wsbackend/AsyncHandler.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 18:15:36 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 18:15:36 +0100
commitd2b45c5442aeb0e02f251916ae1beb06830ef4c1 (patch)
treeb5587ad618f0780c7e7443195cda652d9a2eadbb /module/remote/wsbackend/AsyncHandler.py
parentrenamed most events, push events to webui (diff)
downloadpyload-d2b45c5442aeb0e02f251916ae1beb06830ef4c1.tar.xz
render download progress
Diffstat (limited to 'module/remote/wsbackend/AsyncHandler.py')
-rw-r--r--module/remote/wsbackend/AsyncHandler.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/module/remote/wsbackend/AsyncHandler.py b/module/remote/wsbackend/AsyncHandler.py
index 5c08aa96d..99ffe9894 100644
--- a/module/remote/wsbackend/AsyncHandler.py
+++ b/module/remote/wsbackend/AsyncHandler.py
@@ -19,6 +19,7 @@
import re
from Queue import Queue, Empty
from threading import Lock
+from time import time
from mod_pywebsocket.msgutil import receive_message
@@ -58,6 +59,7 @@ class AsyncHandler(AbstractHandler):
req.interval = self.PROGRESS_INTERVAL
req.events = self.EVENT_PATTERN
req.mode = Mode.STANDBY
+ req.t = time() # time when update should be pushed
self.clients.append(req)
@lock
@@ -120,6 +122,7 @@ class AsyncHandler(AbstractHandler):
def mode_running(self, req):
""" Listen for events, closes socket when returning True """
try:
+ # block length of update interval if necessary
ev = req.queue.get(True, req.interval)
try:
self.send(req, ev)
@@ -130,9 +133,15 @@ class AsyncHandler(AbstractHandler):
self.send(req, ev)
except Empty:
+ pass
+
+ if req.t <= time():
# TODO: server status is not enough
# modify core api to include progress? think of other needed information to show
+ # eta is quite wrong currently
# notifications
-
self.send(req, self.api.getServerStatus())
- self.send(req, self.api.getProgressInfo()) \ No newline at end of file
+ self.send(req, self.api.getProgressInfo())
+
+ # update time for next update
+ req.t = time() + req.interval \ No newline at end of file