Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 25, 2023
1 parent 2649b72 commit b6c7a4a
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions jupyter_core/utils/patched_nest_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Distributed under the terms of the Modified BSD License.
# Note: copied from https://github.com/ipyflow/ipyflow/blob/8e4bc5cb8d4231b9b69f4f9dce867b8101164ac5/core/ipyflow/kernel/patched_nest_asyncio.py
import asyncio
import sys


def apply(loop=None):
Expand All @@ -29,19 +28,15 @@ def step(task, exc=None):
curr_tasks[task._loop] = curr_task

Task = asyncio.Task
if sys.version_info >= (3, 7, 0):
def enter_task(loop, task):
curr_tasks[loop] = task

def enter_task(loop, task):
curr_tasks[loop] = task
def leave_task(loop, task):
curr_tasks.pop(loop, None)

def leave_task(loop, task):
curr_tasks.pop(loop, None)

asyncio.tasks._enter_task = enter_task
asyncio.tasks._leave_task = leave_task
curr_tasks = asyncio.tasks._current_tasks # type: ignore
else:
curr_tasks = Task._current_tasks # type: ignore
asyncio.tasks._enter_task = enter_task
asyncio.tasks._leave_task = leave_task
curr_tasks = asyncio.tasks._current_tasks # type: ignore
try:
step_orig = Task._Task__step # type: ignore
Task._Task__step = step # type: ignore
Expand Down

0 comments on commit b6c7a4a

Please sign in to comment.