put the socket emit in seperate thread, hopefully will help
This commit is contained in:
parent
d355656f30
commit
a6ab05f334
|
@ -10,6 +10,7 @@ app.config['SECRET KEY'] = 'dev'
|
||||||
#url = "sakimori.space:5000"
|
#url = "sakimori.space:5000"
|
||||||
#app.config['SERVER_NAME'] = url
|
#app.config['SERVER_NAME'] = url
|
||||||
socketio = SocketIO(app)
|
socketio = SocketIO(app)
|
||||||
|
socket_thread = None
|
||||||
|
|
||||||
# Serve React App
|
# Serve React App
|
||||||
@app.route('/', defaults={'path': ''})
|
@app.route('/', defaults={'path': ''})
|
||||||
|
@ -126,7 +127,10 @@ def handle_new_conn(data):
|
||||||
|
|
||||||
def update_loop():
|
def update_loop():
|
||||||
global game_states
|
global game_states
|
||||||
|
global socket_thread
|
||||||
while True:
|
while True:
|
||||||
|
if socket_thread is not None:
|
||||||
|
socket_thread.join()
|
||||||
game_states = []
|
game_states = []
|
||||||
game_ids = iter(master_games_dic.copy().keys())
|
game_ids = iter(master_games_dic.copy().keys())
|
||||||
for game_id in game_ids:
|
for game_id in game_ids:
|
||||||
|
@ -245,5 +249,7 @@ def update_loop():
|
||||||
|
|
||||||
state["update_pause"] -= 1
|
state["update_pause"] -= 1
|
||||||
|
|
||||||
socketio.emit("states_update", game_states)
|
socket_thread = threading.Thread(target=socketio.emit, args=("states_update", game_states))
|
||||||
|
socket_thread.start()
|
||||||
|
#socketio.emit("states_update", game_states)
|
||||||
time.sleep(8)
|
time.sleep(8)
|
Loading…
Reference in a new issue