Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/asgiref/files/, dev-python/asgiref/
Date: Sun, 01 Aug 2021 09:39:47
Message-Id: 1627810779.e12abce98b08dd2e503de5f42a6de4d70cb6b10f.mgorny@gentoo
1 commit: e12abce98b08dd2e503de5f42a6de4d70cb6b10f
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Aug 1 09:38:42 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Aug 1 09:39:39 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e12abce9
7
8 dev-python/asgiref: Remove old
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-python/asgiref/Manifest | 2 -
13 dev-python/asgiref/asgiref-3.3.4.ebuild | 32 ---
14 dev-python/asgiref/asgiref-3.4.0.ebuild | 27 ---
15 .../files/asgiref-3.3.4-py310-warnings.patch | 235 ---------------------
16 4 files changed, 296 deletions(-)
17
18 diff --git a/dev-python/asgiref/Manifest b/dev-python/asgiref/Manifest
19 index 735c3399505..a97fd0db9b5 100644
20 --- a/dev-python/asgiref/Manifest
21 +++ b/dev-python/asgiref/Manifest
22 @@ -1,3 +1 @@
23 -DIST asgiref-3.3.4.tar.gz 30780 BLAKE2B f14a5ae3cc3d0c67a827b4b8d002c9d92388285f7388b7ac439b11fbe2e72b6dee5a9c38637e6b5189e3a3625d24a806b5aeff1ffc41861fd4947d7b7c4621ba SHA512 e224ce82f9156e3efde316f3e209a9fbb9494cb9347d6652e19ed130921143de8d3e2a45f50352bf13fcdf229c291e68a0348fff31de144e58cd1a53b4eb0c31
24 -DIST asgiref-3.4.0.tar.gz 32396 BLAKE2B bbf80c4f5bfc7eaf2f27896913a59f522643de35a5eac45807b88f0b2deef6acef408a6d3abb939c4653554415028b5eea68e99ee45247e384848c554ab61c7c SHA512 259dd6fafcd4db73554a4bd26f6000b33c61e8e4d42294bc22826bc95e89959bcc3f9f97d8f0b5dc7e0cf8420890ea8ab368232b4046254e8c91ad010f6509c0
25 DIST asgiref-3.4.1.tar.gz 32529 BLAKE2B 4b5f3b33e165468d71711cf28a5a6161866cd7495140cb67ff028aba5a2586414783d2fa7ce744e99e269714d9d64a019a67c852fd4546ba1f71625473010b9f SHA512 af266fc3eac58c21f2ab3f66e522067388f9cf232b17344fb5afbc408c034e61a1cce02362ec5dc494985beef099800f75cf7de28dc057c45e4bcb973b0a6dbe
26
27 diff --git a/dev-python/asgiref/asgiref-3.3.4.ebuild b/dev-python/asgiref/asgiref-3.3.4.ebuild
28 deleted file mode 100644
29 index 30ca06005aa..00000000000
30 --- a/dev-python/asgiref/asgiref-3.3.4.ebuild
31 +++ /dev/null
32 @@ -1,32 +0,0 @@
33 -# Copyright 2020-2021 Gentoo Authors
34 -# Distributed under the terms of the GNU General Public License v2
35 -
36 -EAPI=7
37 -
38 -PYTHON_COMPAT=( python3_{7..10} pypy3 )
39 -inherit distutils-r1
40 -
41 -DESCRIPTION="ASGI utilities (successor to WSGI)"
42 -HOMEPAGE="
43 - https://asgi.readthedocs.io/en/latest/
44 - https://github.com/django/asgiref/
45 - https://pypi.org/project/asgiref/"
46 -SRC_URI="mirror://pypi/${PN::1}/${PN}/${P}.tar.gz"
47 -
48 -LICENSE="BSD"
49 -SLOT="0"
50 -KEYWORDS="amd64 arm arm64 ~hppa ~ia64 ppc ppc64 ~riscv sparc x86"
51 -
52 -RDEPEND="
53 - $(python_gen_cond_dep '
54 - dev-python/typing-extensions[${PYTHON_USEDEP}]
55 - ' python3_7 pypy3)"
56 -BDEPEND="
57 - test? ( dev-python/pytest-asyncio[${PYTHON_USEDEP}] )"
58 -
59 -PATCHES=(
60 - # Provided to upstream: https://github.com/django/asgiref/pull/262
61 - "${FILESDIR}/${P}-py310-warnings.patch"
62 -)
63 -
64 -distutils_enable_tests pytest
65
66 diff --git a/dev-python/asgiref/asgiref-3.4.0.ebuild b/dev-python/asgiref/asgiref-3.4.0.ebuild
67 deleted file mode 100644
68 index d0582cfb518..00000000000
69 --- a/dev-python/asgiref/asgiref-3.4.0.ebuild
70 +++ /dev/null
71 @@ -1,27 +0,0 @@
72 -# Copyright 2020-2021 Gentoo Authors
73 -# Distributed under the terms of the GNU General Public License v2
74 -
75 -EAPI=7
76 -
77 -PYTHON_COMPAT=( python3_{8..10} pypy3 )
78 -inherit distutils-r1
79 -
80 -DESCRIPTION="ASGI utilities (successor to WSGI)"
81 -HOMEPAGE="
82 - https://asgi.readthedocs.io/en/latest/
83 - https://github.com/django/asgiref/
84 - https://pypi.org/project/asgiref/"
85 -SRC_URI="mirror://pypi/${PN::1}/${PN}/${P}.tar.gz"
86 -
87 -LICENSE="BSD"
88 -SLOT="0"
89 -KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86"
90 -
91 -RDEPEND="
92 - $(python_gen_cond_dep '
93 - dev-python/typing-extensions[${PYTHON_USEDEP}]
94 - ' python3_7 pypy3)"
95 -BDEPEND="
96 - test? ( dev-python/pytest-asyncio[${PYTHON_USEDEP}] )"
97 -
98 -distutils_enable_tests pytest
99
100 diff --git a/dev-python/asgiref/files/asgiref-3.3.4-py310-warnings.patch b/dev-python/asgiref/files/asgiref-3.3.4-py310-warnings.patch
101 deleted file mode 100644
102 index 1cd017ddfbd..00000000000
103 --- a/dev-python/asgiref/files/asgiref-3.3.4-py310-warnings.patch
104 +++ /dev/null
105 @@ -1,235 +0,0 @@
106 -From 0c9e989f18b99ea24a1fb3ea2c8a66fd295c2178 Mon Sep 17 00:00:00 2001
107 -From: Ekaterina Vaartis <vaartis@××××××××.ch>
108 -Date: Thu, 20 May 2021 19:44:15 +0300
109 -Subject: [PATCH] Fix deprecation warnings for python 3.10
110 -
111 -asyncio.get_event_loop was marked as deprecated, the documnetation
112 -now refers to asyncio.get_running_loop([1])
113 -
114 -asyncio.ensure_future issues a deprecation warning if there is no
115 -running event loop([2]), so use asyncio.run which creates and destroys the
116 -loop itself
117 -
118 -asyncio.gather issues a warning if run outside of event
119 -loop (i.e. there is no running event loop)([3]), so wrap it into an
120 -async def
121 -
122 -explicit passing of coroutine objects to asyncio.wait is deprecated
123 -since 3.8([4]), so wrap them in asyncio.create_task
124 -
125 -plus, add 3.10 to tox.ini
126 -
127 -[1]: https://docs.python.org/3.10/library/asyncio-eventloop.html#asyncio.get_event_loop
128 -[2]: https://docs.python.org/3.10/library/asyncio-future.html#asyncio.ensure_future
129 -[3]: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.gather
130 -[4]: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.wait
131 ----
132 - asgiref/compatibility.py | 14 ++++++++++++++
133 - asgiref/server.py | 8 ++++----
134 - asgiref/sync.py | 15 ++++++++++-----
135 - tests/test_sync.py | 19 ++++++++++++++-----
136 - tests/test_sync_contextvars.py | 3 ++-
137 - tox.ini | 2 +-
138 - 6 files changed, 45 insertions(+), 16 deletions(-)
139 -
140 -diff --git a/asgiref/compatibility.py b/asgiref/compatibility.py
141 -index eccaee0..614b2e6 100644
142 ---- a/asgiref/compatibility.py
143 -+++ b/asgiref/compatibility.py
144 -@@ -1,5 +1,6 @@
145 - import asyncio
146 - import inspect
147 -+import sys
148 -
149 -
150 - def is_double_callable(application):
151 -@@ -45,3 +46,16 @@ def guarantee_single_callable(application):
152 - if is_double_callable(application):
153 - application = double_to_single_callable(application)
154 - return application
155 -+
156 -+
157 -+if sys.version_info >= (3, 7):
158 -+ # these were introduced in 3.7
159 -+ get_running_loop = asyncio.get_running_loop
160 -+ run_future = asyncio.run
161 -+ create_task = asyncio.create_task
162 -+else:
163 -+ # marked as deprecated in 3.10, did not exist before 3.7
164 -+ get_running_loop = asyncio.get_event_loop
165 -+ run_future = asyncio.ensure_future
166 -+ # does nothing, this is fine for <3.7
167 -+ create_task = lambda task: task
168 -diff --git a/asgiref/server.py b/asgiref/server.py
169 -index f975f78..fb1c394 100644
170 ---- a/asgiref/server.py
171 -+++ b/asgiref/server.py
172 -@@ -3,7 +3,7 @@ import logging
173 - import time
174 - import traceback
175 -
176 --from .compatibility import guarantee_single_callable
177 -+from .compatibility import get_running_loop, guarantee_single_callable, run_future
178 -
179 - logger = logging.getLogger(__name__)
180 -
181 -@@ -56,7 +56,7 @@ class StatelessServer:
182 - """
183 - Runs the asyncio event loop with our handler loop.
184 - """
185 -- event_loop = asyncio.get_event_loop()
186 -+ event_loop = get_running_loop()
187 - asyncio.ensure_future(self.application_checker())
188 - try:
189 - event_loop.run_until_complete(self.handle())
190 -@@ -88,12 +88,12 @@ class StatelessServer:
191 - input_queue = asyncio.Queue()
192 - application_instance = guarantee_single_callable(self.application)
193 - # Run it, and stash the future for later checking
194 -- future = asyncio.ensure_future(
195 -+ future = run_future(
196 - application_instance(
197 - scope=scope,
198 - receive=input_queue.get,
199 - send=lambda message: self.application_send(scope, message),
200 -- )
201 -+ ),
202 - )
203 - self.application_instances[scope_id] = {
204 - "input_queue": input_queue,
205 -diff --git a/asgiref/sync.py b/asgiref/sync.py
206 -index 6b87c7e..9476e66 100644
207 ---- a/asgiref/sync.py
208 -+++ b/asgiref/sync.py
209 -@@ -9,6 +9,7 @@ import weakref
210 - from concurrent.futures import Future, ThreadPoolExecutor
211 - from typing import Any, Callable, Dict, Optional, Union
212 -
213 -+from .compatibility import get_running_loop
214 - from .current_thread_executor import CurrentThreadExecutor
215 - from .local import Local
216 -
217 -@@ -132,7 +133,7 @@ class AsyncToSync:
218 - self.main_event_loop = None
219 - else:
220 - try:
221 -- self.main_event_loop = asyncio.get_event_loop()
222 -+ self.main_event_loop = get_running_loop()
223 - except RuntimeError:
224 - # There's no event loop in this thread. Look for the threadlocal if
225 - # we're inside SyncToAsync
226 -@@ -151,7 +152,7 @@ class AsyncToSync:
227 - def __call__(self, *args, **kwargs):
228 - # You can't call AsyncToSync from a thread with a running event loop
229 - try:
230 -- event_loop = asyncio.get_event_loop()
231 -+ event_loop = get_running_loop()
232 - except RuntimeError:
233 - pass
234 - else:
235 -@@ -238,7 +239,11 @@ class AsyncToSync:
236 - tasks = asyncio.Task.all_tasks(loop)
237 - for task in tasks:
238 - task.cancel()
239 -- loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
240 -+
241 -+ async def gather():
242 -+ await asyncio.gather(*tasks, return_exceptions=True)
243 -+
244 -+ loop.run_until_complete(gather())
245 - for task in tasks:
246 - if task.cancelled():
247 - continue
248 -@@ -320,7 +325,7 @@ class SyncToAsync:
249 -
250 - # If they've set ASGI_THREADS, update the default asyncio executor for now
251 - if "ASGI_THREADS" in os.environ:
252 -- loop = asyncio.get_event_loop()
253 -+ loop = get_running_loop()
254 - loop.set_default_executor(
255 - ThreadPoolExecutor(max_workers=int(os.environ["ASGI_THREADS"]))
256 - )
257 -@@ -370,7 +375,7 @@ class SyncToAsync:
258 - pass
259 -
260 - async def __call__(self, *args, **kwargs):
261 -- loop = asyncio.get_event_loop()
262 -+ loop = get_running_loop()
263 -
264 - # Work out what thread to run the code in
265 - if self._thread_sensitive:
266 -diff --git a/tests/test_sync.py b/tests/test_sync.py
267 -index cf0e0c5..8ed76a7 100644
268 ---- a/tests/test_sync.py
269 -+++ b/tests/test_sync.py
270 -@@ -9,6 +9,7 @@ from unittest import TestCase
271 -
272 - import pytest
273 -
274 -+from asgiref.compatibility import create_task, get_running_loop
275 - from asgiref.sync import ThreadSensitiveContext, async_to_sync, sync_to_async
276 -
277 -
278 -@@ -33,12 +34,17 @@ async def test_sync_to_async():
279 - assert result == 42
280 - assert end - start >= 1
281 - # Set workers to 1, call it twice and make sure that works right
282 -- loop = asyncio.get_event_loop()
283 -- old_executor = loop._default_executor
284 -+ loop = get_running_loop()
285 -+ old_executor = loop._default_executor or ThreadPoolExecutor()
286 - loop.set_default_executor(ThreadPoolExecutor(max_workers=1))
287 - try:
288 - start = time.monotonic()
289 -- await asyncio.wait([async_function(), async_function()])
290 -+ await asyncio.wait(
291 -+ [
292 -+ create_task(async_function()),
293 -+ create_task(async_function()),
294 -+ ]
295 -+ )
296 - end = time.monotonic()
297 - # It should take at least 2 seconds as there's only one worker.
298 - assert end - start >= 2
299 -@@ -428,7 +434,7 @@ async def test_thread_sensitive_outside_async():
300 - result["thread"] = threading.current_thread()
301 -
302 - # Run it (in supposed parallel!)
303 -- await asyncio.wait([outer(result_1), inner(result_2)])
304 -+ await asyncio.wait([create_task(outer(result_1)), create_task(inner(result_2))])
305 -
306 - # They should not have run in the main thread, but in the same thread
307 - assert result_1["thread"] != threading.current_thread()
308 -@@ -449,7 +455,10 @@ async def test_thread_sensitive_with_context_matches():
309 - async with ThreadSensitiveContext():
310 - # Run it (in supposed parallel!)
311 - await asyncio.wait(
312 -- [store_thread_async(result_1), store_thread_async(result_2)]
313 -+ [
314 -+ create_task(store_thread_async(result_1)),
315 -+ create_task(store_thread_async(result_2)),
316 -+ ]
317 - )
318 -
319 - await fn()
320 -diff --git a/tests/test_sync_contextvars.py b/tests/test_sync_contextvars.py
321 -index b1027aa..9665bf9 100644
322 ---- a/tests/test_sync_contextvars.py
323 -+++ b/tests/test_sync_contextvars.py
324 -@@ -4,6 +4,7 @@ import time
325 -
326 - import pytest
327 -
328 -+from asgiref.compatibility import create_task
329 - from asgiref.sync import ThreadSensitiveContext, async_to_sync, sync_to_async
330 -
331 - contextvars = pytest.importorskip("contextvars")
332 -@@ -25,7 +26,7 @@ async def test_thread_sensitive_with_context_different():
333 - await store_thread(result)
334 -
335 - # Run it (in true parallel!)
336 -- await asyncio.wait([fn(result_1), fn(result_2)])
337 -+ await asyncio.wait([create_task(fn(result_1)), create_task(fn(result_2))])
338 -
339 - # They should not have run in the main thread, and on different threads
340 - assert result_1["thread"] != threading.current_thread()