mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-02 10:41:30 +08:00
Replace RLock-based synchronization with a pipe-based method queue for lock-free coordination between worker threads and main thread. Key changes: - Add PollableMethodQueue class using os.pipe() for wake-up signaling - Non-blocking pipe (both ends) for BSD compatibility (FreeBSD, OpenBSD) - Unified event loop using single poller.select() - no more futures.wait() - Better graceful shutdown with connection draining within grace period - Rename _keep to keepalived_conns, remove _lock entirely - Add handle_exit() for SIGTERM, improve handle_quit() for SIGQUIT - Add set_accept_enabled() for dynamic connection acceptance control - Add wait_for_and_dispatch_events() with EINTR handling Performance improvement: ~8% at high concurrency due to reduced lock contention and non-blocking pipe operations. Tests: 40 tests covering PollableMethodQueue, graceful shutdown, keepalive management, error handling, and BSD compatibility. Fixes #3146 Closes #3157