Josh VanderLinden avatar Josh VanderLinden committed 9e2b442

Requesting status update if we haven't had one recently

Comments (0)

Files changed (2)

 # Maintainer: Josh VanderLinden <arch@cloudlery.com>
 pkgname=zedify
-pkgver=20130513
-pkgrel=7
+pkgver=20130514
+pkgrel=1
 pkgdesc="Deliver message notifications to remote machines"
 arch=('any')
 url="http://bitbucket.org/codekoala/zedify"
 buffer with unseen messages or when you type into such a buffer.
 """
 
-from itertools import count
 from threading import Thread, Event
 import atexit
 import os
 import re
 import sh
 import site
+import time
 
 import zmq
 
 
         def receive(ev):
             log.info('About to receive messages')
+
+            last_update = 0
             p = zmq.Poller()
             p.register(SUB, zmq.POLLIN)
 
-            ticks = count()
-            request_status()
-
             try:
                 while not ev.is_set():
+                    # request a status update if we haven't received anything
+                    # recently
+                    if time.time() - last_update >= REFRESH_INTERVAL:
+                        request_status()
+
                     try:
                         socks = dict(p.poll(1000))
                         if SUB in socks:
+                            last_update = time.time()
                             handle(SUB.recv_json())
                     except:
                         log.exception('Error')
 
-                    n = next(ticks)
-                    if n >= REFRESH_INTERVAL:
-                        request_status()
-                        ticks = count()
-
             finally:
                 SUB.close()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.