File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,34 @@ async def default_handler(context: BasicCrawlingContext) -> None:
110110 run_result = await run_actor (actor )
111111
112112 assert run_result .status == 'SUCCEEDED'
113+
114+
115+ async def test_actor_sequential_contexts (make_actor : MakeActorFunction , run_actor : RunActorFunction ) -> None :
116+ """Test that Actor and Actor() can be used in sequential async context manager blocks."""
117+
118+ async def main () -> None :
119+ async with Actor as actor :
120+ actor ._exit_process = False
121+ assert actor ._is_initialized is True
122+
123+ # Actor after Actor.
124+ async with Actor as actor :
125+ actor ._exit_process = False
126+ assert actor ._is_initialized is True
127+
128+ # Actor() after Actor.
129+ async with Actor (exit_process = False ) as actor :
130+ assert actor ._is_initialized is True
131+
132+ # Actor() after Actor().
133+ async with Actor (exit_process = False ) as actor :
134+ assert actor ._is_initialized is True
135+
136+ # Actor after Actor().
137+ async with Actor as actor :
138+ assert actor ._is_initialized is True
139+
140+ actor = await make_actor (label = 'actor-sequential-contexts' , main_func = main )
141+ run_result = await run_actor (actor )
142+
143+ assert run_result .status == 'SUCCEEDED'
You can’t perform that action at this time.
0 commit comments