Add timeout around inf-streamer suite
Since with the new actorc injection seems to be hanging? Not sure what exactly the issue is but likely races again during teardown between the `.run_in_actor()` remote-exc capture and any actorc after the `portal.cancel()`.. Also tossed in a bp to figure out why actorcs aren't actually showing outside the `trio.run()`..?actor_cancelled_exc_type
							parent
							
								
									4fbe54991e
								
							
						
					
					
						commit
						80f822f494
					
				|  | @ -11,6 +11,9 @@ from itertools import repeat | ||||||
| import pytest | import pytest | ||||||
| import trio | import trio | ||||||
| import tractor | import tractor | ||||||
|  | from tractor._exceptions import ( | ||||||
|  |     ActorCancelled, | ||||||
|  | ) | ||||||
| from tractor._testing import ( | from tractor._testing import ( | ||||||
|     tractor_test, |     tractor_test, | ||||||
| ) | ) | ||||||
|  | @ -124,7 +127,10 @@ def test_multierror( | ||||||
|         ) as nursery: |         ) as nursery: | ||||||
| 
 | 
 | ||||||
|             await nursery.run_in_actor(assert_err, name='errorer1') |             await nursery.run_in_actor(assert_err, name='errorer1') | ||||||
|             portal2 = await nursery.run_in_actor(assert_err, name='errorer2') |             portal2 = await nursery.run_in_actor( | ||||||
|  |                 assert_err, | ||||||
|  |                 name='errorer2', | ||||||
|  |             ) | ||||||
| 
 | 
 | ||||||
|             # get result(s) from main task |             # get result(s) from main task | ||||||
|             try: |             try: | ||||||
|  | @ -137,7 +143,15 @@ def test_multierror( | ||||||
|         # here we should get a ``BaseExceptionGroup`` containing exceptions |         # here we should get a ``BaseExceptionGroup`` containing exceptions | ||||||
|         # from both subactors |         # from both subactors | ||||||
| 
 | 
 | ||||||
|     with pytest.raises(BaseExceptionGroup): |     with pytest.raises( | ||||||
|  |         expected_exception=( | ||||||
|  |             tractor.RemoteActorError, | ||||||
|  | 
 | ||||||
|  |             # ?TODO, should it be this?? | ||||||
|  |             # like `trio`'s strict egs? | ||||||
|  |             BaseExceptionGroup, | ||||||
|  |         ), | ||||||
|  |     ): | ||||||
|         trio.run(main) |         trio.run(main) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -233,8 +247,9 @@ async def stream_forever(): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @tractor_test | @tractor_test | ||||||
| async def test_cancel_infinite_streamer(start_method): | async def test_cancel_infinite_streamer( | ||||||
| 
 |     start_method: str, | ||||||
|  | ): | ||||||
|     # stream for at most 1 seconds |     # stream for at most 1 seconds | ||||||
|     with ( |     with ( | ||||||
|         trio.fail_after(4), |         trio.fail_after(4), | ||||||
|  | @ -291,6 +306,7 @@ async def test_some_cancels_all( | ||||||
|     num_actors_and_errs: tuple, |     num_actors_and_errs: tuple, | ||||||
|     start_method: str, |     start_method: str, | ||||||
|     loglevel: str, |     loglevel: str, | ||||||
|  |     debug_mode: bool, | ||||||
| ): | ): | ||||||
|     ''' |     ''' | ||||||
|     Verify a subset of failed subactors causes all others in |     Verify a subset of failed subactors causes all others in | ||||||
|  | @ -306,6 +322,11 @@ async def test_some_cancels_all( | ||||||
|         ria_func, |         ria_func, | ||||||
|         da_func, |         da_func, | ||||||
|     ) = num_actors_and_errs |     ) = num_actors_and_errs | ||||||
|  |     with trio.fail_after( | ||||||
|  |         3 | ||||||
|  |         if not debug_mode | ||||||
|  |         else 999 | ||||||
|  |     ): | ||||||
|         try: |         try: | ||||||
|             async with tractor.open_nursery() as an: |             async with tractor.open_nursery() as an: | ||||||
| 
 | 
 | ||||||
|  | @ -354,13 +375,21 @@ async def test_some_cancels_all( | ||||||
| 
 | 
 | ||||||
|         except first_err as _err: |         except first_err as _err: | ||||||
|             err = _err |             err = _err | ||||||
|  | 
 | ||||||
|             if isinstance(err, BaseExceptionGroup): |             if isinstance(err, BaseExceptionGroup): | ||||||
|  | 
 | ||||||
|                 assert len(err.exceptions) == num_actors |                 assert len(err.exceptions) == num_actors | ||||||
|                 for exc in err.exceptions: |                 for exc in err.exceptions: | ||||||
|  | 
 | ||||||
|  |                     # TODO, figure out why these aren't being set? | ||||||
|  |                     if isinstance(exc, ActorCancelled): | ||||||
|  |                         breakpoint() | ||||||
|  | 
 | ||||||
|                     if isinstance(exc, tractor.RemoteActorError): |                     if isinstance(exc, tractor.RemoteActorError): | ||||||
|                         assert exc.boxed_type == err_type |                         assert exc.boxed_type == err_type | ||||||
|                     else: |                     else: | ||||||
|                         assert isinstance(exc, trio.Cancelled) |                         assert isinstance(exc, trio.Cancelled) | ||||||
|  | 
 | ||||||
|             elif isinstance(err, tractor.RemoteActorError): |             elif isinstance(err, tractor.RemoteActorError): | ||||||
|                 assert err.boxed_type == err_type |                 assert err.boxed_type == err_type | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue