File deprecate-gaiohttp-worker.patch of Package python-gunicorn
From b6a04c398958c9ff7a8992ba8d2d4fbc806326ba Mon Sep 17 00:00:00 2001
From: Nikolay Kim <nikolay.kim@affirm.com>
Date: Tue, 27 Dec 2016 10:16:48 -0800
Subject: [PATCH] deprecate AiohttpWorker and use GunicornWebWorker from
aiohttp if available
---
gunicorn/workers/gaiohttp.py | 15 ++++++++++++---
tests/test_gaiohttp.py | 5 ++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/gunicorn/workers/gaiohttp.py b/gunicorn/workers/gaiohttp.py
index 899e9a3..de4233a 100644
--- a/gunicorn/workers/gaiohttp.py
+++ b/gunicorn/workers/gaiohttp.py
@@ -4,14 +4,23 @@
# See the NOTICE for more information.
import sys
+from gunicorn import utils
-if sys.version_info >= (3, 3):
+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
+
+ utils.warn(
+ "AiohttpWorker is deprecated please install aiohttp 1.2+ "
+ "and set aiohttp.worker.GunicornWebWorker as a custom worker ")
+
__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 asyncio worker")
diff --git a/tests/test_gaiohttp.py b/tests/test_gaiohttp.py
index 5440556..7305c58 100644
--- a/tests/test_gaiohttp.py
+++ b/tests/test_gaiohttp.py
@@ -6,9 +6,8 @@
import unittest
import pytest
aiohttp = pytest.importorskip("aiohttp")
-
-
-from aiohttp.wsgi import WSGIServerHttpProtocol
+WSGIServerHttpProtocol = pytest.importorskip(
+ "aiohttp.wsgi.WSGIServerHttpProtocol")
import asyncio
from gunicorn.workers import gaiohttp