Skip to content

Commit b710973

Browse files
authored
Merge pull request #32 from obilodeau/fix-concurrency-bugs
Fixed important regressions due to socket.io and web server in eventlet affecting since 0.5.0 maybe even 0.4.0
2 parents 98ce153 + 91d9fff commit b710973

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

ceopardy/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@
7878
# flask-cors is optional; prod serves everything from the same origin.
7979
pass
8080

81+
# Use threading mode so the WSGI layer stays plain Werkzeug — its debugger
82+
# and exception logging just work. If someone fronts this with gunicorn
83+
# (see README), they pick the worker class at the CLI level (-k eventlet).
8184
socketio = SocketIO(
8285
app,
8386
cors_allowed_origins="*",
84-
async_mode="eventlet",
87+
async_mode="threading",
8588
)
8689
db = SQLAlchemy(app)
8790

ceopardy/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def _cmd_serve(args):
3535
print(f" Host: http://localhost:{port}/host")
3636
if debug:
3737
print(" Debug: ON (verbose logging + auto-reload)")
38-
socketio.run(app, host=host, port=port, debug=debug)
38+
# Werkzeug is the only WSGI server we use here. Flask-SocketIO refuses it
39+
# by default; we opt in because Ceopardy is meant for single-operator
40+
# local use (binds to 127.0.0.1, see README on exposing via nginx).
41+
socketio.run(app, host=host, port=port, debug=debug, allow_unsafe_werkzeug=True)
3942

4043

4144
def _walk(traversable, prefix=""):

run.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@
2525
# debug=False.
2626
# WARNING: This app is not ready to be exposed on the network.
2727
# Game host interface would be exposed.
28-
socketio.run(app, host="127.0.0.1", port=5000, debug=True)
28+
# allow_unsafe_werkzeug: Flask-SocketIO refuses Werkzeug otherwise. See
29+
# the same opt-in (and rationale) in ceopardy/__main__.py:_cmd_serve.
30+
socketio.run(
31+
app,
32+
host="127.0.0.1",
33+
port=5000,
34+
debug=True,
35+
allow_unsafe_werkzeug=True,
36+
)

0 commit comments

Comments
 (0)