Skip to content
Myr

Add BaseEvent interface (#260)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Florimond Manca · committed by GitHub · parent c0554e9 · Browse files · 3 files+23 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+23 added−1 removed

  • other:+23 added−1 removed

3 files+23 added−1 removed

modified:httpx/concurrency/asyncio.py+4 added
15 unmodified lines
1617from .base import (18 BaseBackgroundManager,19 BasePoolSemaphore,20 BaseEvent,21 BaseQueue,22 BaseReader,23 BaseWriter,24 ConcurrencyBackend,
194 unmodified lines
219220 def create_queue(self, max_size: int) -> BaseQueue:221 return typing.cast(BaseQueue, asyncio.Queue(maxsize=max_size))222223 def create_event(self) -> BaseEvent:224 return typing.cast(BaseEvent, asyncio.Event())225226 def background_manager(227 self, coroutine: typing.Callable, args: typing.Any228 ) -> "BackgroundManager":229 return BackgroundManager(coroutine, args)
21 unmodified lines
modified:httpx/concurrency/base.py+18 added
80 unmodified lines
81 async def put(self, value: typing.Any) -> None:82 raise NotImplementedError() # pragma: no cover838485class BaseEvent:86 """87 An event object. Abstracts away any asyncio-specific interfaces.88 """8990 def set(self) -> None:91 raise NotImplementedError() # pragma: no cover9293 def is_set(self) -> bool:94 raise NotImplementedError() # pragma: no cover9596 async def wait(self) -> None:97 raise NotImplementedError() # pragma: no cover9899100class BasePoolSemaphore:101 """102 A semaphore for use with connection pooling.103
55 unmodified lines
159160 def create_queue(self, max_size: int) -> BaseQueue:161 raise NotImplementedError() # pragma: no cover162163 def create_event(self) -> BaseEvent:164 raise NotImplementedError() # pragma: no cover165166 def background_manager(167 self, coroutine: typing.Callable, args: typing.Any168 ) -> "BaseBackgroundManager":169 raise NotImplementedError() # pragma: no cover
13 unmodified lines
modified:httpx/dispatch/asgi.py+1 added-1 removed
80 unmodified lines
81 app = self.app82 app_exc = None83 status_code = None84 headers = None85 response_started_or_failed = asyncio.Event()85 response_started_or_failed = self.backend.create_event()86 response_body = BodyIterator(self.backend)87 request_stream = request.stream()8889 async def receive() -> dict:
107 unmodified lines