Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Use various engines #4568

Merged
merged 20 commits into from
Jan 2, 2022
Merged

[Python] Use various engines #4568

merged 20 commits into from
Jan 2, 2022

Conversation

waghanza
Copy link
Collaborator

@waghanza waghanza commented Aug 22, 2021

Hi,

This PR starts using various engines (or setup) per python frameworks.

The idea is to run framework on built-in capability (if provided) and other deployment options.

The is a lot of server engines (gunicorn,uvicorn,bjoern,uwsgi ...). The idea is to test with officially supported deployment options + some few accurate options (hypercorn for ASGI for example)

I, on purpose, keep a small list of setups per framework :

  • I'm the only one maintaining / creating new features
  • The results could be hard to read / understand

Here is the list of engines / setups we can use for each frameworks


Feel free to react / give me some feedback @dutradda @douglasfarinelli @almarklein @abersheeran @RobertoPrevato @webknjaz @defnull @cyclone @bdarnell @vitalik @kgriffs @tiangolo @bloodbare @masipcat @josephmancuso @pgjones @ahopkins @tomchristie @Ayehavgunne @taoufik07 @Bogdanp @gi0baro

Regards,

@waghanza waghanza marked this pull request as draft August 22, 2021 09:01
@waghanza waghanza requested review from greed2411 and ahopkins August 22, 2021 09:01
@waghanza
Copy link
Collaborator Author

@RobertoPrevato with daphne, I have

Traceback (most recent call last):
  File "blacksheep/baseapp.pyx", line 79, in blacksheep.baseapp.BaseApplication.handle
TypeError: user_info() missing 1 required positional argument: 'id'

The docker file use is

FROM python:3.9-slim
WORKDIR /usr/src/app
RUN apt-get -qq update
RUN apt-get -qy install build-essential
COPY server.py server.py
COPY requirements.txt requirements.txt
RUN pip install daphne
RUN pip install -r requirements.txt
CMD daphne -b 0.0.0.0 -p 3000 server:app

have you ever tried https://github.com/django/daphne ?

@RobertoPrevato
Copy link
Contributor

RobertoPrevato commented Aug 23, 2021

Hi @waghanza, thanks for the heads up. I never tried Daphne, I'm currently supporting Hypercorn and Uvicorn including integration tests. I will soon check why and if I can make BlackSheep work with it.
ASGI is supposed to be a common interface so I didn't think necessary to test my web framework with every single implementation. 😄

@waghanza
Copy link
Collaborator Author

ASGI is supposed to be a common interface so I didn't think necessary to test my web framework with every single implementation. 😄

indeed. the idea of this project is to produce some results from frameworks (but with various setups for this PR). in this PR context it could be accurate to have results (for blacksheep) with at least to setups (uvicorn and hypercorn could be enough). I'll disable daphne (I prefer to stick on officially supported setups for now)

@RobertoPrevato
Copy link
Contributor

Yes and I think it's a very good idea to test with different setups, it's very useful for benchmarks to show these scenarios.

@abersheeran
Copy link
Contributor

@waghanza index.py can run on uvicorn, hypercorn, daphne or other servers that implement the ASGI interface.

@waghanza waghanza force-pushed the variants branch 6 times, most recently from 220da84 to 033cf8b Compare October 14, 2021 19:46
Copy link
Contributor

@josephmancuso josephmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look OK

@kgriffs
Copy link

kgriffs commented Nov 8, 2021

@waghanza Falcon should be runnable with any compliant ASGI server. We currently test with uvicorn, daphne, and hypercorn:

https://github.com/falconry/falcon/blob/master/tests/asgi/test_asgi_servers.py#L535

That being said, we recommend uvicorn where performance is concerned.

cc @vytas7

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 2, 2022

@ahopkins I have a 500 on daphne for sanic

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sanic/app.py", line 1715, in __call__
    await asgi_app()
  File "/usr/local/lib/python3.9/site-packages/sanic/asgi.py", line 223, in __call__
    await self.sanic_app.handle_exception(self.request, e)
  File "/usr/local/lib/python3.9/site-packages/sanic/app.py", line 736, in handle_exception
    await self.dispatch(
  File "/usr/local/lib/python3.9/site-packages/sanic/signals.py", line 191, in dispatch
    return await dispatch
  File "/usr/local/lib/python3.9/site-packages/sanic/signals.py", line 130, in _dispatch
    group, handlers, params = self.get(event, condition=condition)
  File "/usr/local/lib/python3.9/site-packages/sanic/signals.py", line 92, in get
    group, param_basket = self.find_route(
TypeError: 'NoneType' object is not callable

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 2, 2022

@Ayehavgunne Same issue on tonberry with daphne

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/daphne/http_protocol.py", line 163, in process
    self.application_queue = yield maybeDeferred(
TypeError: __call__() got an unexpected keyword argument 'receive'

@ahopkins
Copy link
Member

ahopkins commented Jan 2, 2022

@ahopkins I have a 500 on daphne for sanic

This is a known thing. Daphne does not execute the life cycle startup events. Last I checked it was an implementation issue with Daphne.

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 2, 2022

This is a known thing. Daphne does not execute the life cycle startup events. Last I checked it was an implementation issue with Daphne.

Ok. Then probably worth to add some point in the doc https://sanicframework.org/en/guide/deployment/running.html#asgi

@waghanza waghanza marked this pull request as ready for review January 2, 2022 14:41
@waghanza waghanza merged commit b2c1201 into variants Jan 2, 2022
@waghanza waghanza deleted the python_engines branch January 2, 2022 14:41
@ahopkins
Copy link
Member

ahopkins commented Jan 2, 2022

Thanks @waghanza. I just updated to docs.

For reference for anyone coming across this: django/daphne#264

@bgervan
Copy link

bgervan commented Feb 13, 2023

Does anyone has public result with the different engines?

@waghanza
Copy link
Collaborator Author

Not yet @bgervan. We need to have a customized frontend first.

Actual results shows only 1 engine => https://web-frameworks-benchmark.netlify.app/result

waghanza added a commit that referenced this pull request May 22, 2023
* fix outdated rake config

* remove duplicated config

* wrong merge for php dockerfile

* use phalcon 4.x

* merge imi

* update ci

* add workerman config for imi

* bad version required for phalcon

* update ci config

* lint

* add swoole / workerman for mixphp

* merge node and uwebsockets versions for chubbyjs

* update ci config

* fix

* fix

* add ssl layer in php containers

* enable ci for engines

* fix ci

* fix chiubbyjs

* use built-in php ssl module

* missing config for nest

* update sails config

* lint

* use phalcon 5.0.0alpha6

* fix roadrunner config for spiral

* fix tower config

* fix phalcon config

* lint files

* remove duplicate upload on container

* show docker version used on CI

* quotify paths for file uploaded to containers

* downgrade imi to 2.0.11

* [Javascript] Add opine (#4839)

* unrestrict imi version

* fix docker error due to duplicate upload onto containers

* deduplicates framework build steps

* use phalcon beta

* avoid multiple gemfiles for ruby based projects

* typo

* [Python] Use various engines (#4568)

* start pythonization

* run ci only for python

* add blacksheep

* add bottle

* add cyclone

* add gunicorn for django

* disable daphne for blacksheep

* add hypercorn for django

* add asgi adapter for django

* add asgi support for baize

* add accurate engine for python frameworks

* missing cheroo

* add command for waitress / uwsgi

* typo

* complete python suite

* remove daphne for blacksheep

* typo

* use safe navigation

* remove meinheld patching

* fix

* remove outdated LOCs

* fix CI for uwebsocket based frameworks

* make gunicorn default choice for python

* fix low-http-server

* start working on golang

* fix specs

* pass on golang frameworks

* fix deprecation warning on npm usage

* Create codeql-analysis.yml

* fix gramework

* bad config for basolato

* remove debug

* add pcntl extension for workeman

* typo

* wrong container definition for php

* configuration changes

* use non lts version for uwsgi

* beautify

* fix go dockerfile

* typos

* remove codeql

* restore old behavior

* fix go dockerfiles

* restore data

* restore imi variants

* restore laravel s

* restore mixphp variants

* restore one fpm

* restore slim variants

* restore sunrise router variants

* restore yii swoole

* fix aurora

* typo

* update go dockerfile

* restore basolato

* restore basolator

* fix some php containers

* typo

* restore turbo polka

* reduce PR size

* reduce PR size

* reduce PR size

* restore fyrejet uwebsocket

* beautify

* upgrade node

* reduce PR size

* reduce PR size

* typo

* typo

* typo

* cleanup

* cleanup

* fix bottle

* add engines

* fix deprecated action

* reduce ci tasks

* reduce ci tasks

* fix CI

* increase CI tasks

* increase CI tasks

* increase CI tasks

* increase CI tasks

* increase CI tasks

* increase CI tasks

* increase CI tasks

* typo

* align config files

* fix amber

* typo

* typo

* missing static files into go containers

* typo

* missing files onto container

* modify c dockerfile

* missing dub.sdl for dlang

* fix go builds

* fix routejs config for uws

* fix nginx config for php

* missing ts compilation for adonis

* use openjdk 17

* fix adonis config

* fix haskell

* fix yada

* fix luminus

* fix routerling

* fix masonite

* fix basolato

* fix basicphp

* fix workerman

* fix antidot

* fix chubbyphp

* update dub

* add redis / pcntl for formo

* add pcntl for hyperf

* beautify

* cleanup

* update

* typo on config

* pcntl is a php module not extension

* lint

* run I only on first engine

* restore cpp / java frameworks

* typos on some  dockerfiles

* fix java config

* add properties files onto java containers

* use jammy image for donkey

* typo on dart config

* typo

* typo on java config

* specify jvm level for kotlin based frameworks

* add config file onto kotlin containers

* add road runner config file onto containers

* update camping config

* html entity issue in r dockerfile

* fix hug config

* add yml files for ligt-4j

* fix micronaut dockerfile

* typo on config for spring

* fix light-4j config

* add gradle build files for micronaut

* fix micronaut build

* fix event moudle load for php

* use first engine

* update

* add run.sh

* update scorper

* update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants