mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-04 11:41:32 +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
Gunicorn
--------
.. image:: https://img.shields.io/pypi/v/gunicorn.svg?style=flat
:alt: PyPI version
:target: https://pypi.python.org/pypi/gunicorn
.. image:: https://img.shields.io/pypi/pyversions/gunicorn.svg
:alt: Supported Python versions
:target: https://pypi.python.org/pypi/gunicorn
.. image:: https://github.com/benoitc/gunicorn/actions/workflows/tox.yml/badge.svg
:alt: Build Status
:target: https://github.com/benoitc/gunicorn/actions/workflows/tox.yml
.. image:: https://github.com/benoitc/gunicorn/actions/workflows/lint.yml/badge.svg
:alt: Lint Status
:target: https://github.com/benoitc/gunicorn/actions/workflows/lint.yml
Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork
worker model ported from Ruby's Unicorn_ project. The Gunicorn server is broadly
compatible with various web frameworks, simply implemented, light on server
resource usage, and fairly speedy.
Feel free to join us in `#gunicorn`_ on `Libera.chat`_.
Documentation
-------------
The documentation is hosted at https://docs.gunicorn.org.
Installation
------------
Gunicorn requires **Python 3.x >= 3.7**.
Install from PyPI::
$ pip install gunicorn
Usage
-----
Basic usage::
$ gunicorn [OPTIONS] APP_MODULE
Where ``APP_MODULE`` is of the pattern ``$(MODULE_NAME):$(VARIABLE_NAME)``. The
module name can be a full dotted path. The variable name refers to a WSGI
callable that should be found in the specified module.
Example with test app::
$ cd examples
$ gunicorn --workers=2 test:app
Contributing
------------
See `our complete contributor's guide <CONTRIBUTING.md>`_ for more details.
License
-------
Gunicorn is released under the MIT License. See the LICENSE_ file for more
details.
.. _Unicorn: https://bogomips.org/unicorn/
.. _`#gunicorn`: https://web.libera.chat/?channels=#gunicorn
.. _`Libera.chat`: https://libera.chat/
.. _LICENSE: https://github.com/benoitc/gunicorn/blob/master/LICENSE
Languages
Python
99.9%