File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,9 @@ async def init(self) -> None:
200200 if self ._is_initialized :
201201 raise RuntimeError ('The Actor was already initialized!' )
202202
203+ # Make sure that the currently initialized instance is also available through the global `Actor` proxy
204+ cast (Proxy , Actor ).__wrapped__ = self
205+
203206 self ._is_exiting = False
204207 self ._was_final_persist_state_emitted = False
205208
Original file line number Diff line number Diff line change 1616import apify ._actor
1717from apify import Actor
1818from apify ._actor import _ActorType
19+ from apify ._configuration import Configuration
1920
2021
2122async def test_actor_properly_init_with_async () -> None :
@@ -35,6 +36,13 @@ async def test_actor_init() -> None:
3536 assert my_actor ._is_initialized is False
3637
3738
39+ async def test_actor_global_works () -> None :
40+ non_default_configuration = Configuration (actor_full_name = 'Actor McActorson, esq.' )
41+
42+ async with Actor (configuration = non_default_configuration ):
43+ assert Actor .configuration is non_default_configuration
44+
45+
3846async def test_double_init_raises_error (prepare_test_env : Callable ) -> None :
3947 async with Actor :
4048 assert Actor ._is_initialized
You can’t perform that action at this time.
0 commit comments