emmett-framework / granian

A Rust HTTP server for Python applications
BSD 3-Clause "New" or "Revised" License
2.75k stars 81 forks source link

Avoid to run Python event-loop in WSGI protocol #364

Open gi0baro opened 2 months ago

gi0baro commented 2 months ago

There's no really any need for the Python event-loop to be running in WSGI protocol; as of today the only reason we run it is to have code shared with other protocols in src/workers.rs.

Not identified any performance gain from these, but avoiding the event-loop ticks definitely makes sense. Implications on the how to actually run the Rust serving loop yet to be made, possibly a block_on wrapped into a py.allow_threads will be enough.

gi0baro commented 1 month ago

From preliminary tests it seems performance is not affected. At least on MacOS arm.