Skip to content

Commit

Permalink
🐛 fix async close under uvloop (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret authored Oct 25, 2024
1 parent c9cdc22 commit 7640299
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.11.904 (2024-10-25)
=====================

- Improve (async) close procedure when used in a ``uvloop``.

2.11.903 (2024-10-22)
=====================

Expand Down
2 changes: 1 addition & 1 deletion src/urllib3/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is protected via CODEOWNERS
from __future__ import annotations

__version__ = "2.11.903"
__version__ = "2.11.904"
6 changes: 5 additions & 1 deletion src/urllib3/contrib/ssa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ def close(self) -> None:

try:
if hasattr(self._sock, "shutdown"):
self._sock.shutdown(SHUT_RD)
try:
self._sock.shutdown(SHUT_RD)
except TypeError: # uvloop don't support shutdown!
if hasattr(self._sock, "close"):
self._sock.close()
elif hasattr(self._sock, "close"):
self._sock.close()
# we have to force call close() on our sock object in UDP ctx. (even after shutdown)
Expand Down

0 comments on commit 7640299

Please sign in to comment.