11from typing import (
22 Callable ,
33 Coroutine ,
4- Generator ,
54 Iterable ,
65 AsyncIterator ,
76 TypeVar ,
@@ -45,25 +44,6 @@ async def await_wrapper(*args: Any, **kwargs: Any) -> T:
4544 return await_wrapper
4645
4746
48- class PingPong :
49- """
50- Signal to the event loop which gets returned unchanged
51-
52- The coroutine yields to the event loop but is resumed
53- immediately, without running others in the meantime.
54- This is mainly useful for ensuring the event loop is used.
55- """
56-
57- def __await__ (self ) -> "Generator[PingPong, Any, Any]" :
58- return (yield self )
59-
60-
61- async def inside_loop () -> bool :
62- """Test whether there is an active event loop available"""
63- signal = PingPong ()
64- return await signal is signal
65-
66-
6747class Schedule :
6848 r"""
6949 Signal to the event loop to adopt and run new coroutines
@@ -136,9 +116,7 @@ def sync(test_case: Callable[..., Coroutine[None, Any, Any]], /) -> Callable[...
136116 Mark an ``async def`` test case to be run synchronously with children
137117
138118 This provides a primitive "event loop" which only responds
139- to the :py:class:`PingPong`, :py:class:`Schedule`, :py:class:`Switch`
140- and :py:class:`Lock`. This loop is appropriate for tests that need
141- to check concurrency.
119+ to :py:class:`Schedule`, :py:class:`Switch` and :py:class:`Lock`.
142120
143121 It should be applied as a decorator on an ``async def`` function, which
144122 is then turned into a synchronous callable that will run the ``async def``
@@ -159,9 +137,7 @@ def run_sync(*args: Any, **kwargs: Any):
159137 result = e .args [0 ] if e .args else None
160138 assert result is None , f"got '{ result !r} ' expected 'None'"
161139 else :
162- if isinstance (event , PingPong ):
163- run_queue .appendleft ((coro , event ))
164- elif isinstance (event , Schedule ):
140+ if isinstance (event , Schedule ):
165141 run_queue .extend ((new_coro , None ) for new_coro in event .coros )
166142 run_queue .append ((coro , event ))
167143 elif isinstance (event , Switch ):
0 commit comments