77from asyncio import events
88from asyncio .events import AbstractEventLoop
99
10-
11-
1210DEBUG = False
1311
1412
@@ -26,6 +24,7 @@ class Py313BaseEventLoop:
2624 into Python's asyncio BaseEventLoop
2725
2826 """
27+
2928 # Lib/asyncio/base_events.py
3029 def _run_forever_setup (self ):
3130 """Prepare the run loop to process events.
@@ -42,7 +41,7 @@ def _run_forever_setup(self):
4241 self ._thread_id = threading .get_ident ()
4342 sys .set_asyncgen_hooks (
4443 firstiter = self ._asyncgen_firstiter_hook ,
45- finalizer = self ._asyncgen_finalizer_hook
44+ finalizer = self ._asyncgen_finalizer_hook ,
4645 )
4746
4847 events ._set_running_loop (self )
@@ -82,17 +81,21 @@ def run_forever(self):
8281 ok_to_patch = False
8382
8483 if not ok_to_patch :
85- raise RuntimeError ("Python 3.12 requires patching asyncio before the async loop starts."
84+ raise RuntimeError (
85+ "Python 3.12 requires patching asyncio before the async loop starts."
8686 " Please import extraasync before setting up your async loop"
8787 )
88- asyncio .base_events .BaseEventLoop ._run_forever_setup = Py313BaseEventLoop ._run_forever_setup
89- asyncio .base_events .BaseEventLoop ._run_forever_cleanup = Py313BaseEventLoop ._run_forever_cleanup
88+ asyncio .base_events .BaseEventLoop ._run_forever_setup = (
89+ Py313BaseEventLoop ._run_forever_setup
90+ )
91+ asyncio .base_events .BaseEventLoop ._run_forever_cleanup = (
92+ Py313BaseEventLoop ._run_forever_cleanup
93+ )
9094 asyncio .base_events .BaseEventLoop .run_forever = Py313BaseEventLoop .run_forever
9195
9296 # Now, it is "B.A.U."
9397
9498
95-
9699if not hasattr (asyncio .BaseEventLoop , "_run_forever_cleanup" ):
97100
98101 warnings .warn (
@@ -150,16 +153,14 @@ def new_run_forever_cleanup():
150153 cb ()
151154 except Exception as exc :
152155 if not DEBUG :
153- warnings .warn (
154- f"""\
156+ warnings .warn (f"""\
155157 Supressed Exception raised on loop callback { cb .__name__ } :
156158 { exc }
157159
158160 set extraasync.async_hooks.DEBUG to True
159161 to have it raised instead.
160162
161- """
162- )
163+ """ )
163164 else :
164165 raise exc
165166 original_clean_up ()
0 commit comments