- Notifications
You must be signed in to change notification settings - Fork 569
Add async transport #4614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async transport #4614
Changes from 1 commit
9f24136 001f36c 401b1bc 3f43d8f 15fa295 ef780f3 f63e46f 1804271 11da869 779a0d6 0895d23 bbf426b 744dc8a fcc8040 9a43d9b b5eda0e 9e380b8 ee44621 d9f7383 d2e647b 859a0e2 4a58ce7 cbecde7 c8bb55a 05a7de7 38246d0 8b226cb 823215e 4eed4fd afd494d fcc7ac3 f659514 8c542ce 30dde67 3392e0e 6c85500 ae5a864 9c537e6 f7554b2 6cb72ad 9171c5d 111861b 4744817 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -581,7 +581,7 @@ class AsyncHttpTransport(HttpTransportCore): | |
| def __init__(self: Self, options: Dict[str, Any]) -> None: | ||
| super().__init__(options) | ||
| # Requires event loop at init time | ||
| self._loop = asyncio.get_running_loop() | ||
| self.loop = asyncio.get_running_loop() | ||
| self.background_tasks: set[asyncio.Task[None]] = set() | ||
| | ||
| def _get_header_value(self: Self, response: Any, header: str) -> Optional[str]: | ||
| | @@ -679,10 +679,10 @@ def capture_envelope(self: Self, envelope: Envelope) -> None: | |
| except RuntimeError: | ||
| # We are in a background thread, not running an event loop, | ||
| # have to launch the task on the loop in a threadsafe way. | ||
| if self._loop and self._loop.is_running(): | ||
| if self.loop and self.loop.is_running(): | ||
| asyncio.run_coroutine_threadsafe( | ||
| self._capture_envelope(envelope), | ||
| self._loop, | ||
| self.loop, | ||
| ) | ||
| else: | ||
| # The event loop is no longer running | ||
| | @@ -793,7 +793,7 @@ def kill(self: Self) -> Optional[asyncio.Task[None]]: # type: ignore | |
| self.background_tasks.clear() | ||
| try: | ||
| # Return the pool cleanup task so caller can await it if needed | ||
| return self._loop.create_task(self._pool.aclose()) # type: ignore | ||
| return self.loop.create_task(self._pool.aclose()) # type: ignore | ||
| except RuntimeError: | ||
| ||
| logger.warning("Event loop not running, aborting kill.") | ||
| return None | ||
| ||
| | ||
Uh oh!
There was an error while loading. Please reload this page.