@@ -1619,26 +1619,16 @@ async def in_task_group(task_status: TaskStatus[None]) -> None:
1619
1619
1620
1620
if sys .version_info >= (3 , 14 ):
1621
1621
1622
- async def no_other_refs () -> list [object ]:
1623
- frame = sys ._getframe (1 )
1624
- coro = get_current_task ().coro
1625
-
1626
- async def get_coro_for_frame (* , task_status : TaskStatus [object ]) -> None :
1627
- my_coro = coro
1628
- while my_coro .cr_frame is not frame :
1629
- my_coro = my_coro .cr_await
1630
- task_status .started (my_coro )
1631
-
1632
- async with create_task_group () as tg :
1633
- return [await tg .start (get_coro_for_frame )]
1622
+ def no_other_refs () -> list [object ]:
1623
+ return [sys ._getframe (1 ).f_generator ]
1634
1624
1635
1625
elif sys .version_info >= (3 , 11 ):
1636
1626
1637
- async def no_other_refs () -> list [object ]:
1627
+ def no_other_refs () -> list [object ]:
1638
1628
return []
1639
1629
else :
1640
1630
1641
- async def no_other_refs () -> list [object ]:
1631
+ def no_other_refs () -> list [object ]:
1642
1632
return [sys ._getframe (1 )]
1643
1633
1644
1634
@@ -1670,7 +1660,7 @@ class _Done(Exception):
1670
1660
exc = e
1671
1661
1672
1662
assert exc is not None
1673
- assert gc .get_referrers (exc ) == await no_other_refs ()
1663
+ assert gc .get_referrers (exc ) == no_other_refs ()
1674
1664
1675
1665
async def test_exception_refcycles_errors (self ) -> None :
1676
1666
"""Test that TaskGroup deletes self._exceptions, and __aexit__ args"""
@@ -1687,7 +1677,7 @@ class _Done(Exception):
1687
1677
exc = excs .exceptions [0 ]
1688
1678
1689
1679
assert isinstance (exc , _Done )
1690
- assert gc .get_referrers (exc ) == await no_other_refs ()
1680
+ assert gc .get_referrers (exc ) == no_other_refs ()
1691
1681
1692
1682
async def test_exception_refcycles_parent_task (self ) -> None :
1693
1683
"""Test that TaskGroup's cancel_scope deletes self._host_task"""
@@ -1708,7 +1698,7 @@ async def coro_fn() -> None:
1708
1698
exc = excs .exceptions [0 ].exceptions [0 ]
1709
1699
1710
1700
assert isinstance (exc , _Done )
1711
- assert gc .get_referrers (exc ) == await no_other_refs ()
1701
+ assert gc .get_referrers (exc ) == no_other_refs ()
1712
1702
1713
1703
async def test_exception_refcycles_propagate_cancellation_error (self ) -> None :
1714
1704
"""Test that TaskGroup deletes cancelled_exc"""
@@ -1725,7 +1715,7 @@ async def test_exception_refcycles_propagate_cancellation_error(self) -> None:
1725
1715
raise
1726
1716
1727
1717
assert isinstance (exc , get_cancelled_exc_class ())
1728
- assert gc .get_referrers (exc ) == await no_other_refs ()
1718
+ assert gc .get_referrers (exc ) == no_other_refs ()
1729
1719
1730
1720
async def test_exception_refcycles_base_error (self ) -> None :
1731
1721
"""
@@ -1748,7 +1738,7 @@ class MyKeyboardInterrupt(KeyboardInterrupt):
1748
1738
exc = excs .exceptions [0 ]
1749
1739
1750
1740
assert isinstance (exc , MyKeyboardInterrupt )
1751
- assert gc .get_referrers (exc ) == await no_other_refs ()
1741
+ assert gc .get_referrers (exc ) == no_other_refs ()
1752
1742
1753
1743
1754
1744
class TestTaskStatusTyping :
0 commit comments