Mercurial > templog
comparison web/settings.py @ 258:03e540c3ec24
fix server side long polling
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 09 Jun 2015 23:29:11 +0800 |
parents | 0a1b642e3086 |
children | 87c20b8c5472 |
comparison
equal
deleted
inserted
replaced
257:d0c29436bb63 | 258:03e540c3ec24 |
---|---|
1 import gevent | 1 import gevent |
2 import fcntl | 2 import fcntl |
3 import hashlib | 3 import hashlib |
4 | |
5 import binascii | |
6 import os | |
4 | 7 |
5 class Settings(object): | 8 class Settings(object): |
6 RAND_SIZE = 15 # 120 bits | 9 RAND_SIZE = 15 # 120 bits |
7 | 10 |
8 """ Handles state updates from both the web UI and from the fridge client. | 11 """ Handles state updates from both the web UI and from the fridge client. |
20 self.event = gevent.event.Event() | 23 self.event = gevent.event.Event() |
21 self.contents = None | 24 self.contents = None |
22 self.epoch = None | 25 self.epoch = None |
23 self.tag = None | 26 self.tag = None |
24 | 27 |
25 self.update(self, None, 'startepoch') | 28 self.update(None, 'startepoch') |
26 | 29 |
27 def wait(self, epoch_tag = None, timeout = None): | 30 def wait(self, epoch_tag = None, timeout = None): |
28 """ returns false if the timeout was hit """ | 31 """ returns false if the timeout was hit """ |
29 if self.epoch_tag() != epoch_tag: | 32 if self.epoch_tag() != epoch_tag: |
30 # has alredy changed | 33 # has alredy changed |