-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Deprecate gaiohttp worker and document alternatives #1569
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,13 +123,20 @@ A string referring to one of the following bundled classes: | |
* ``gevent`` - Requires gevent >= 0.13 | ||
* ``tornado`` - Requires tornado >= 0.2 | ||
* ``gthread`` - Python 2 requires the futures package to be installed | ||
* ``gaiohttp`` - Requires Python 3.4 and aiohttp >= 0.21.5 | ||
* ``gaiohttp`` - Deprecated. Please use | ||
``aiohttp.worker.GunicornWebWorker`` instead. See :ref:`asyncio-workers` | ||
for more information on how to use it. | ||
|
||
Optionally, you can provide your own worker by giving Gunicorn a | ||
Python path to a subclass of ``gunicorn.workers.base.Worker``. | ||
This alternative syntax will load the gevent class: | ||
``gunicorn.workers.ggevent.GeventWorker``. | ||
|
||
.. deprecated:: 19.8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
The ``gaiohttp`` worker is deprecated. Please use | ||
``aiohttp.worker.GunicornWebWorker`` instead. See | ||
:ref:`asyncio-workers` for more information on how to use it. | ||
|
||
.. _threads: | ||
|
||
threads | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Example command to run the example: | ||
# | ||
# $ gunicorn flaskapp_aiohttp_wsgi:aioapp -k aiohttp.worker.GunicornWebWorker | ||
# | ||
|
||
from aiohttp import web | ||
from aiohttp_wsgi import WSGIHandler | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/') | ||
def hello(): | ||
return 'Hello, world!' | ||
|
||
|
||
def make_aiohttp_app(app): | ||
wsgi_handler = WSGIHandler(app) | ||
aioapp = web.Application() | ||
aioapp.router.add_route('*', '/{path_info:.*}', wsgi_handler) | ||
return aioapp | ||
|
||
aioapp = make_aiohttp_app(app) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -624,12 +624,19 @@ class WorkerClass(Setting): | |
* ``gevent`` - Requires gevent >= 0.13 | ||
* ``tornado`` - Requires tornado >= 0.2 | ||
* ``gthread`` - Python 2 requires the futures package to be installed | ||
* ``gaiohttp`` - Requires Python 3.4 and aiohttp >= 0.21.5 | ||
* ``gaiohttp`` - Deprecated. Please use | ||
``aiohttp.worker.GunicornWebWorker`` instead. See :ref:`asyncio-workers` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem. just tell it's deprecated. |
||
for more information on how to use it. | ||
|
||
Optionally, you can provide your own worker by giving Gunicorn a | ||
Python path to a subclass of ``gunicorn.workers.base.Worker``. | ||
This alternative syntax will load the gevent class: | ||
``gunicorn.workers.ggevent.GeventWorker``. | ||
|
||
.. deprecated:: 19.8 | ||
The ``gaiohttp`` worker is deprecated. Please use | ||
``aiohttp.worker.GunicornWebWorker`` instead. See | ||
:ref:`asyncio-workers` for more information on how to use it. | ||
""" | ||
|
||
class WorkerThreads(Setting): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,23 @@ | |
|
||
import sys | ||
|
||
if sys.version_info >= (3, 3): | ||
from gunicorn import util | ||
|
||
if sys.version_info >= (3, 4): | ||
try: | ||
import aiohttp # NOQA | ||
except ImportError: | ||
raise RuntimeError("You need aiohttp installed to use this worker.") | ||
else: | ||
from gunicorn.workers._gaiohttp import AiohttpWorker | ||
try: | ||
from aiohttp.worker import GunicornWebWorker as AiohttpWorker | ||
except ImportError: | ||
from gunicorn.workers._gaiohttp import AiohttpWorker | ||
|
||
util.warn( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this kind of thing should be using Python's inbuilt warning logging facilities, with a DeprecationWarning. This may be a separarte issue if there are other similar depreciation warnings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"The 'gaiohttp' worker is deprecated. Please install 'aiohttp' " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would would reformulate by saying that "The 'gaiohttp' worker is deprecated. Please look at "link to worker page" for an alternative worker supporting asyncio. |
||
"and pass 'aiohttp.worker.GunicornWebWorker' to --worker-class." | ||
) | ||
__all__ = ['AiohttpWorker'] | ||
else: | ||
raise RuntimeError("You need Python >= 3.3 to use the asyncio worker") | ||
raise RuntimeError("You need Python >= 3.4 to use the gaiohttp worker") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should just mark it as deprecated. documentation is already here to point to external asyncio workers. "The 'gaiohttp' worker is deprecated. Please look at "link to worker page" for an alternative worker supporting asyncio."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man, i just started using it this week! :)