forked from goodboy/tractor
				
			Draft test-doc for "out-of-band" `asyncio.Task`..
Since there's no way to activate `greenback`'s portal in such cases, we should at least have a test verifying our very loud error about the inability to support this usage..remotes/1757153874605917753/main
							parent
							
								
									f199cac5e8
								
							
						
					
					
						commit
						66a7d660f6
					
				|  | @ -150,6 +150,18 @@ def pytest_generate_tests(metafunc): | |||
|         metafunc.parametrize("start_method", [spawn_backend], scope='module') | ||||
| 
 | ||||
| 
 | ||||
| # TODO: a way to let test scripts (like from `examples/`) | ||||
| # guarantee they won't registry addr collide! | ||||
| # @pytest.fixture | ||||
| # def open_test_runtime( | ||||
| #     reg_addr: tuple, | ||||
| # ) -> AsyncContextManager: | ||||
| #     return partial( | ||||
| #         tractor.open_nursery, | ||||
| #         registry_addrs=[reg_addr], | ||||
| #     ) | ||||
| 
 | ||||
| 
 | ||||
| def sig_prog(proc, sig): | ||||
|     "Kill the actor-process with ``sig``." | ||||
|     proc.send_signal(sig) | ||||
|  |  | |||
|  | @ -218,10 +218,9 @@ def expect_any_of( | |||
|         ) | ||||
| 
 | ||||
|     return expected_patts | ||||
|     # yield child | ||||
| 
 | ||||
| 
 | ||||
| def test_pause_from_asyncio_task( | ||||
| def test_sync_pause_from_aio_task( | ||||
|     spawn, | ||||
|     ctlc: bool | ||||
|     # ^TODO, fix for `asyncio`!! | ||||
|  | @ -327,3 +326,25 @@ def test_pause_from_asyncio_task( | |||
| 
 | ||||
|     child.sendline('c') | ||||
|     child.expect(EOF) | ||||
| 
 | ||||
| 
 | ||||
| def test_sync_pause_from_non_greenbacked_aio_task(): | ||||
|     ''' | ||||
|     Where the `breakpoint()` caller task is NOT spawned by | ||||
|     `tractor.to_asyncio` and thus never activates | ||||
|     a `greenback.ensure_portal()` beforehand, presumably bc the task | ||||
|     was started by some lib/dep as in often seen in the field. | ||||
| 
 | ||||
|     Ensure sync pausing works when the pause is in, | ||||
| 
 | ||||
|     - the root actor running in infected-mode? | ||||
|       |_ since we don't need any IPC to acquire the debug lock? | ||||
|       |_ is there some way to handle this like the non-main-thread case? | ||||
| 
 | ||||
|     All other cases need to error out appropriately right? | ||||
| 
 | ||||
|     - for any subactor we can't avoid needing the repl lock.. | ||||
|       |_ is there a way to hook into `asyncio.ensure_future(obj)`? | ||||
| 
 | ||||
|     ''' | ||||
|     pass | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue