Pyjo-Reactor-Gevent
Low level event reactor with gevent support for Pyjoyment.
Pyjo.Reactor.Gevent is a reactor of Pyjoyment on the hub of gevent, whose
loop of libev or libuv watches the handles and runs the timers, so that the
servers of Pyjoyment, daemon, prefork and prethread, and its user agent
run along with the greenlets of a program of gevent.
Installation
From PyPI, with Pyjoyment and gevent, which it depends on:
pip install Pyjo-Reactor-Gevent
or, in a project managed with uv:
uv add Pyjo-Reactor-Gevent
The development version is installed from the Git repository:
pip install git+https://github.com/pyjoyment/Pyjo-Reactor-Gevent
Usage
Select the reactor with PYJO_REACTOR before Pyjo.IOLoop is loaded:
PYJO_REACTOR=Pyjo.Reactor.Gevent python myapp.py daemon
PYJO_REACTOR=Pyjo.Reactor.Gevent python myapp.py prefork
The reactor runs in the greenlet that starts it, and the other greenlets of the program run while it waits for events. A blocking request of the user agent waits in the greenlet that makes it, without blocking the others.
gevent runs on libev by default. Its loop of libuv needs cffi:
pip install Pyjo-Reactor-Gevent cffi
GEVENT_LOOP=libuv-cffi PYJO_REACTOR=Pyjo.Reactor.Gevent python myapp.py daemon
With gevent.monkey.patch_all(), the threads of the program are greenlets, so
each greenlet has a Pyjo.IOLoop.singleton of its own, and
Pyjo.Server.Prethread and Pyjo.IOLoop.ChildProcess do not work.
Examples
examples/hello_world_gevent.py runs Pyjo.HelloWorld on the server of
Pyjoyment on gevent until the signal INT or TERM, in a with block, which
closes the listen sockets of the server at its end:
import os
# The reactor of Pyjoyment on gevent, selected before Pyjo.IOLoop is loaded
os.environ['PYJO_REACTOR'] = 'Pyjo.Reactor.Gevent'
import Pyjo.HelloWorld # noqa: E402
import Pyjo.Server.Daemon # noqa: E402
# The server of Pyjoyment on gevent, until the signal INT or TERM, which closes its listen sockets at the end of the block
with Pyjo.Server.Daemon.new(app=Pyjo.HelloWorld.new(), listen=['http://*:3000']) as daemon:
daemon.run()
$ python examples/hello_world_gevent.py
Web application available at http://127.0.0.1:3000
$ curl http://127.0.0.1:3000/
Your Pyjo is working!
examples/loopback_gevent.py is a server of Pyjoyment and its user agent on
the hub of gevent, a blocking request, which runs the event loop until the
response, and the class of the reactor and whether it runs on the hub of
gevent, which Build checks with the wheel:
import os
# The reactor of Pyjoyment on gevent, selected before Pyjo.IOLoop is loaded
os.environ['PYJO_REACTOR'] = 'Pyjo.Reactor.Gevent'
import Pyjo.HelloWorld # noqa: E402
import Pyjo.IOLoop # noqa: E402
import Pyjo.Server.Daemon # noqa: E402
import Pyjo.UserAgent # noqa: E402
import gevent # noqa: E402
# The server, on a port that the system picks, and the user agent, in the same event loop, which close their sockets at
# the end of the block
with (
Pyjo.Server.Daemon.new(app=Pyjo.HelloWorld.new(), listen=['http://127.0.0.1'], silent=True) as daemon,
Pyjo.UserAgent.new(ioloop=Pyjo.IOLoop.singleton) as ua,
):
# A blocking request, which runs the event loop of the server on the hub of gevent until the response
tx = ua.get(f'http://127.0.0.1:{daemon.start().ports()[0]}/')
reactor = Pyjo.IOLoop.singleton.reactor
print(type(reactor).__name__, 'gevent' if getattr(reactor, 'hub', None) is gevent.get_hub() else 'other')
print(tx.result.code, tx.result.text)
$ python examples/loopback_gevent.py
Pyjo_Reactor_Gevent gevent
200 Your Pyjo is working!
examples/greenlets_gevent.py is a server of Pyjoyment in the main greenlet,
along with two greenlets of the application that request it, one with a socket
of gevent and one with a blocking request of the user agent of Pyjoyment:
import os
# The reactor of Pyjoyment on gevent, selected before Pyjo.IOLoop is loaded
os.environ['PYJO_REACTOR'] = 'Pyjo.Reactor.Gevent'
import Pyjo.HelloWorld # noqa: E402
import Pyjo.IOLoop # noqa: E402
import Pyjo.Server.Daemon # noqa: E402
import Pyjo.UserAgent # noqa: E402
import gevent # noqa: E402
import gevent.socket # noqa: E402
# A greenlet with a socket of gevent, which waits in the hub of gevent, where the server of Pyjoyment runs
def with_socket(port):
with gevent.socket.create_connection(('127.0.0.1', port)) as sock:
sock.sendall(b'GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n\r\n')
response = b''
while b'\r\n' not in response and (chunk := sock.recv(4096)):
response += chunk
status = response.split(b'\r\n')[0].decode()
return f'gevent.socket: {status}'
# A greenlet with a blocking request of the user agent of Pyjoyment, whose event loop of its own waits in the greenlet
def with_user_agent(port):
with Pyjo.UserAgent.new() as ua:
tx = ua.get(f'http://127.0.0.1:{port}/')
return f'Pyjo.UserAgent: {tx.result.code} {tx.result.text}'
# The server, on a port that the system picks, which runs in the main greenlet until the greenlets are done, and closes its
# listen sockets at the end of the block
with Pyjo.Server.Daemon.new(app=Pyjo.HelloWorld.new(), listen=['http://127.0.0.1'], silent=True) as daemon:
port = daemon.start().ports()[0]
greenlets = [gevent.spawn(with_socket, port), gevent.spawn(with_user_agent, port)]
gevent.spawn(lambda: (gevent.joinall(greenlets), Pyjo.IOLoop.stop()))
Pyjo.IOLoop.start()
for greenlet in greenlets:
print(greenlet.value)
$ python examples/greenlets_gevent.py
gevent.socket: HTTP/1.1 200 OK
Pyjo.UserAgent: 200 Your Pyjo is working!
Documentation
The API of the module and the examples are on Read the Docs.
Status
A reactor of Pyjoyment in a distribution of its own, as Pyjo-Reactor-Twisted and Pyjo-Reactor-Uvloop.
Metadata
Release files for Pyjo-Reactor-Gevent 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyjo_reactor_gevent-0.1.0.tar.gz | 23.3 kB | With provenance | Details for pyjo_reactor_gevent-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyjo_reactor_gevent-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyjo_reactor_gevent-0.1.0-py3-none-any.whl |
Total release size: 36.3 kB
Release files / pyjo_reactor_gevent-0.1.0.tar.gz
| Download URL | pyjo_reactor_gevent-0.1.0.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22fdb5042e1f1fc05385e9b2064a7fb1d251047e81ce59327802f66a45d737e1
|
|
BLAKE2b-256 checksum How to use checksums |
0ac57335a3cbc22f2b7de7b276f7d2d19ac99befc6d14e1794d61182aee1ea68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / pyjo_reactor_gevent-0.1.0-py3-none-any.whl
| Download URL | pyjo_reactor_gevent-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c6b4b780f02c20fd2d6303059ce2baa0804142540e4afbffbd15706c6f1f874
|
|
BLAKE2b-256 checksum How to use checksums |
520b163a184d22ab3c9305dfb0aa539347028818ad0be2c93e7ddd2710794fa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for Pyjo-Reactor-Gevent 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyjo_reactor_gevent-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.