def ws_downloads(): uwsgi.websocket_handshake() while True: uwsgi.websocket_recv_nb() # for close() gevent.sleep(2) try: payload = json.dumps(rtorrent.downloads()) except: payload = json.dumps({'error': "can't connect to rtorrent"}) uwsgi.websocket_send(payload)
def downloads(): try: return json.dumps(rtorrent.downloads()) except: abort(503)