From: Tom Christie Date: Fri, 29 Nov 2019 11:21:46 +0000 (+0000) Subject: Drop Queue from concurrency backends, since it's no longer required (#562) X-Git-Tag: 0.9.0~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fccc04da4b9490d2d1ff99600f374aa8800176b;p=thirdparty%2Fhttpx.git Drop Queue from concurrency backends, since it's no longer required (#562) * Drop Queue from concurrency backends, since it's no longer required * Drop unused import --- diff --git a/httpx/concurrency/asyncio.py b/httpx/concurrency/asyncio.py index d3febbb3..e7ed63ab 100644 --- a/httpx/concurrency/asyncio.py +++ b/httpx/concurrency/asyncio.py @@ -11,7 +11,6 @@ from .base import ( BaseBackgroundManager, BaseEvent, BasePoolSemaphore, - BaseQueue, BaseSocketStream, ConcurrencyBackend, TimeoutFlag, @@ -325,9 +324,6 @@ class AsyncioBackend(ConcurrencyBackend): def get_semaphore(self, limits: PoolLimits) -> BasePoolSemaphore: return PoolSemaphore(limits) - def create_queue(self, max_size: int) -> BaseQueue: - return typing.cast(BaseQueue, asyncio.Queue(maxsize=max_size)) - def create_event(self) -> BaseEvent: return typing.cast(BaseEvent, asyncio.Event()) diff --git a/httpx/concurrency/base.py b/httpx/concurrency/base.py index 2109c212..a8d44f07 100644 --- a/httpx/concurrency/base.py +++ b/httpx/concurrency/base.py @@ -70,18 +70,6 @@ class BaseSocketStream: raise NotImplementedError() # pragma: no cover -class BaseQueue: - """ - A FIFO queue. Abstracts away any asyncio-specific interfaces. - """ - - async def get(self) -> typing.Any: - raise NotImplementedError() # pragma: no cover - - async def put(self, value: typing.Any) -> None: - raise NotImplementedError() # pragma: no cover - - class BaseEvent: """ An event object. Abstracts away any asyncio-specific interfaces. @@ -169,9 +157,6 @@ class ConcurrencyBackend: except StopAsyncIteration: break - def create_queue(self, max_size: int) -> BaseQueue: - raise NotImplementedError() # pragma: no cover - def create_event(self) -> BaseEvent: raise NotImplementedError() # pragma: no cover diff --git a/httpx/concurrency/trio.py b/httpx/concurrency/trio.py index f2ab919b..ed72d215 100644 --- a/httpx/concurrency/trio.py +++ b/httpx/concurrency/trio.py @@ -1,5 +1,4 @@ import functools -import math import ssl import typing from types import TracebackType @@ -12,7 +11,6 @@ from .base import ( BaseBackgroundManager, BaseEvent, BasePoolSemaphore, - BaseQueue, BaseSocketStream, ConcurrencyBackend, TimeoutFlag, @@ -230,9 +228,6 @@ class TrioBackend(ConcurrencyBackend): def get_semaphore(self, limits: PoolLimits) -> BasePoolSemaphore: return PoolSemaphore(limits) - def create_queue(self, max_size: int) -> BaseQueue: - return Queue(max_size=max_size) - def create_event(self) -> BaseEvent: return Event() @@ -242,17 +237,6 @@ class TrioBackend(ConcurrencyBackend): return BackgroundManager(coroutine, *args) -class Queue(BaseQueue): - def __init__(self, max_size: int) -> None: - self.send_channel, self.receive_channel = trio.open_memory_channel(math.inf) - - async def get(self) -> typing.Any: - return await self.receive_channel.receive() - - async def put(self, value: typing.Any) -> None: - await self.send_channel.send(value) - - class Event(BaseEvent): def __init__(self) -> None: self._event = trio.Event()