Skip to content

Commit

Permalink
fix: go back to pre 3.12 code
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewthetechie committed May 8, 2024
1 parent 1bf74c7 commit 89a419b
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions pydantic_aioredis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def bytes_to_string(data: bytes):


class NestedAsyncIO:
"""Patch asyncio to allow nested event loops."""

__slots__ = [
"_loop",
"orig_run",
Expand Down Expand Up @@ -104,20 +102,13 @@ def _get_event_loop(stacklevel=3):
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) and sys.version_info < (3, 12, 0):
elif sys.version_info >= (3, 9, 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": asyncio.get_event_loop,
}
events._get_event_loop = events.get_event_loop = asyncio.get_event_loop = _get_event_loop
elif 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": asyncio.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 Expand Up @@ -315,6 +306,6 @@ def patch_tornado(self):

def unpatch_tornado(self):
if self.orig_tc:
import tornado.concurrent as tc # noqa
import tornado.concurrent as tc

tc.Future = self.orig_tc

0 comments on commit 89a419b

Please sign in to comment.