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