Skip to content

Commit

Permalink
fix: more loop fixes for 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewthetechie committed May 8, 2024
1 parent 1cfe1e4 commit 9ec811b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pydantic_aioredis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,13 @@ def _get_event_loop(stacklevel=3):
asyncio.Task = asyncio.tasks._CTask = asyncio.tasks.Task = asyncio.tasks._PyTask
self.orig_futures = [asyncio.Future, asyncio.futures._CFuture, asyncio.futures.Future]
asyncio.Future = asyncio.futures._CFuture = asyncio.futures.Future = asyncio.futures._PyFuture
if sys.version_info < (3, 7, 0):
asyncio.tasks._current_tasks = asyncio.tasks.Task._current_tasks
asyncio.all_tasks = asyncio.tasks.Task.all_tasks
elif sys.version_info >= (3, 9, 0):
self.orig_get_loops = {
"events_get_event_loop": events.get_event_loop,
"asyncio_get_event_loop": asyncio.get_event_loop,
}
if sys.version_info <= (3, 12, 0):
self.orig_get_loops["events__get_event_loop"] = (events._get_event_loop,)
events._get_event_loop = events.get_event_loop = asyncio.get_event_loop = _get_event_loop
self.orig_get_loops = {
"events_get_event_loop": events.get_event_loop,
"asyncio_get_event_loop": asyncio.get_event_loop,
}
if sys.version_info >= (3, 10, 0) and sys.version_info < (3, 12, 0):
self.orig_get_loops["events__get_event_loop"] = events._get_event_loop
events._get_event_loop = events.get_event_loop = asyncio.get_event_loop = _get_event_loop
self.orig_run = asyncio.run
asyncio.run = run
asyncio._nest_patched = True
Expand Down

0 comments on commit 9ec811b

Please sign in to comment.