From: Tom Christie Date: Wed, 11 Dec 2019 12:31:05 +0000 (+0000) Subject: Drop unused methods from BaseEvent (#626) X-Git-Tag: 0.9.4~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=869714fbf5f2a1bfda8d6f906930f49032507d7a;p=thirdparty%2Fhttpx.git Drop unused methods from BaseEvent (#626) --- diff --git a/httpx/concurrency/asyncio.py b/httpx/concurrency/asyncio.py index 1912fc0c..c73a1382 100644 --- a/httpx/concurrency/asyncio.py +++ b/httpx/concurrency/asyncio.py @@ -265,4 +265,15 @@ class AsyncioBackend(ConcurrencyBackend): return PoolSemaphore(max_value) def create_event(self) -> BaseEvent: - return typing.cast(BaseEvent, asyncio.Event()) + return Event() + + +class Event(BaseEvent): + def __init__(self) -> None: + self._event = asyncio.Event() + + def set(self) -> None: + self._event.set() + + async def wait(self) -> None: + await self._event.wait() diff --git a/httpx/concurrency/base.py b/httpx/concurrency/base.py index f0c7dc95..da6dd986 100644 --- a/httpx/concurrency/base.py +++ b/httpx/concurrency/base.py @@ -62,12 +62,6 @@ class BaseEvent: def set(self) -> None: raise NotImplementedError() # pragma: no cover - def is_set(self) -> bool: - raise NotImplementedError() # pragma: no cover - - def clear(self) -> None: - raise NotImplementedError() # pragma: no cover - async def wait(self) -> None: raise NotImplementedError() # pragma: no cover diff --git a/httpx/concurrency/trio.py b/httpx/concurrency/trio.py index d607f9c7..6f2ab2d1 100644 --- a/httpx/concurrency/trio.py +++ b/httpx/concurrency/trio.py @@ -170,13 +170,5 @@ class Event(BaseEvent): def set(self) -> None: self._event.set() - def is_set(self) -> bool: - return self._event.is_set() - async def wait(self) -> None: await self._event.wait() - - def clear(self) -> None: - # trio.Event.clear() was deprecated in Trio 0.12. - # https://github.com/python-trio/trio/issues/637 - self._event = trio.Event()