Mercurial > templog
diff web/templog.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 | 8ef52f27cf95 |
children | 205809a8872f 9be8464e4295 |
line wrap: on
line diff
--- a/web/templog.py Tue Jun 09 21:22:10 2015 +0800 +++ b/web/templog.py Tue Jun 09 23:29:11 2015 +0800 @@ -163,12 +163,16 @@ req_etag = request.headers.get('etag', None) if req_etag: # wait for it to change - if not log.fridge_settings.wait(req_etag, timeout=LONG_POLL_TIMEOUT): - response.status = 304 - return "Nothing happened" + # XXX this is meant to return True if it has been woken up + # but it isn't working. Instead compare epochtag below. + log.fridge_settings.wait(req_etag, timeout=config.LONG_POLL_TIMEOUT) + + contents, epoch_tag = log.fridge_settings.get() + if epoch_tag == req_etag: + response.status = 304 + return "Nothing happened" response.set_header('Content-Type', 'application/json') - contents, epoch_tag = client_settings.get() return json.dumps({'params': contents, 'epoch_tag': epoch_tag}) @bottle.get('/<filename:re:.*\.js>')