File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727import contextvars
2828import gc
2929import socket
30+ import sys
3031import threading
3132import time
3233import unittest
@@ -475,8 +476,13 @@ def test_task_factory(self):
475476
476477 def task_factory (loop , coro ):
477478 factory_calls .append (True )
478- # Create task using modern API (Python 3.12+)
479- return asyncio .Task (coro , eager_start = False )
479+ # Create task compatible with all Python versions
480+ if sys .version_info >= (3 , 12 ):
481+ # Python 3.12+: use eager_start=False to opt out of eager execution
482+ return asyncio .Task (coro , eager_start = False )
483+ else :
484+ # Python 3.10-3.11: loop parameter deprecated but still works
485+ return asyncio .Task (coro , loop = loop )
480486
481487 self .loop .set_task_factory (task_factory )
482488 self .assertEqual (self .loop .get_task_factory (), task_factory )
You can’t perform that action at this time.
0 commit comments