Mercurial > templog
diff py/utils.py @ 556:c5f8375b12a2
long polling works
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 09 Jun 2015 23:27:44 +0800 |
parents | 9499bd2f344b |
children | 78c542f03030 |
line wrap: on
line diff
--- a/py/utils.py Mon Jun 08 22:33:04 2015 +0800 +++ b/py/utils.py Tue Jun 09 23:27:44 2015 +0800 @@ -5,6 +5,7 @@ import select import logging import binascii +import json D = logging.debug L = logging.info @@ -134,5 +135,6 @@ except Exception as e: return -1 -def hexnonce(): - return binascii.hexlify(os.urandom(120)) + +def json_load_round_float(s, **args): + return json.loads(s,parse_float = lambda f: round(float(f), 2), **args)