From df4bddaa535e60d9dfd212796d69c30afa9a0a3f Mon Sep 17 00:00:00 2001 From: kermit Date: Wed, 16 Sep 2020 19:24:44 +0100 Subject: [PATCH] Make sure requests runs async --- server-requirements.txt | 1 + server.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server-requirements.txt b/server-requirements.txt index 354709f..1f34fba 100644 --- a/server-requirements.txt +++ b/server-requirements.txt @@ -1,3 +1,4 @@ deemix>=1.3.0 flask flask-socketio +eventlet diff --git a/server.py b/server.py index 19dabc1..4b40f1d 100644 --- a/server.py +++ b/server.py @@ -6,8 +6,10 @@ import subprocess from os import path import json -import requests -from urllib.request import urlopen +import eventlet +requests = eventlet.import_patched('requests') +urlopen = eventlet.import_patched('urllib.request').urlopen + from datetime import datetime from flask import Flask, render_template, request, session, redirect, copy_current_request_context @@ -71,7 +73,6 @@ class SocketInterface(MessageInterface): socketio.emit(message, value) else: socketio.emit(message) - socketio.sleep(0) socket_interface = SocketInterface()