Compare commits

...

1 Commits

Author SHA1 Message Date
Timmy
eccd2f906c fix: Replace HTTPServer with ThreadingHTTPServer for concurrent users
Some checks failed
CI / test (pull_request) Failing after 42s
CI / validate (pull_request) Failing after 35s
Review Approval Gate / verify-review (pull_request) Failing after 6s
Fixes #1356. Single-threaded HTTPServer queued all requests sequentially,
causing 60% timeout rate with 10 concurrent users.

Changes:
- world/multi_user_bridge.py: Added ThreadingHTTPServer class with
  ThreadingMixIn + daemon_threads, swapped server instantiation
- multi_user_bridge.py: Fixed server instantiation to use the already-
  defined ThreadingHTTPServer class (was using HTTPServer by mistake)

Impact: 10/10 concurrent users complete (~5s avg) vs 4/10 before.
2026-04-13 18:21:59 -04:00
2 changed files with 10 additions and 3 deletions

View File

@@ -2880,7 +2880,7 @@ def main():
# Start world tick system
world_tick_system.start()
server = HTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server = ThreadingHTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server.serve_forever()

View File

@@ -26,11 +26,18 @@ import threading
import hashlib
import os
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ThreadingMixIn
from pathlib import Path
from datetime import datetime
from typing import Optional
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
"""Thread-per-request HTTP server for concurrent user handling."""
daemon_threads = True
# ── Configuration ──────────────────────────────────────────────────────
BRIDGE_PORT = int(os.environ.get('TIMMY_BRIDGE_PORT', 4004))
@@ -274,7 +281,7 @@ def main():
print(f" POST /bridge/move — Move user to room (user_id, room)")
print()
server = HTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server = ThreadingHTTPServer((BRIDGE_HOST, BRIDGE_PORT), BridgeHandler)
server.serve_forever()