Description
The _ActorType.__init__ constructor is executed twice when creating an instance of Actor.
Reproduction
I added simple prints to the _ActorType.__init__, _ActorType.__aenter__ and _ActorType.init methods and prepared a simple Actor:
from apify import Actor
async def main() -> None:
async with Actor() as actor:
actor.log.info(f'Hello! Actor={Actor}, actor={actor}.')
Execution:
$ apify run
Run: /home/vdusek/Projects/apify-sdk-python/.venv/bin/python3 -m src
Hello from _ActorType.__init__
Hello from _ActorType.__init__
Hello from _ActorType.__aenter__
Hello from _ActorType.init
[apify] INFO Initializing Actor...
[apify] INFO System info ({"apify_sdk_version": "2.2.2", "apify_client_version": "1.8.1", "crawlee_version": "0.5.3", "python_version": "3.13.2", "os": "linux"})
[apify] INFO Hello! Actor=<apify.Actor>, actor=<apify._actor._ActorType object at 0x7ff7f757fed0>.
[apify] INFO Exiting Actor ({"exit_code": 0})
This does not happen when using the Actor class without an instance, as shown below:
from apify import Actor
async def main() -> None:
async with Actor:
Actor.log.info(f'Hello! Actor={Actor}.')
Output
$ apify run
Run: /home/vdusek/Projects/apify-sdk-python/.venv/bin/python3 -m src
Hello from _ActorType.__init__
Hello from _ActorType.__aenter__
Hello from _ActorType.init
[apify] INFO Initializing Actor...
[apify] INFO System info ({"apify_sdk_version": "2.2.2", "apify_client_version": "1.8.1", "crawlee_version": "0.5.3", "python_version": "3.13.2", "os": "linux"})
[apify] INFO Hello! Actor=<apify.Actor>.
[apify] INFO Exiting Actor ({"exit_code": 0})
Description
The
_ActorType.__init__constructor is executed twice when creating an instance of Actor.Reproduction
I added simple prints to the
_ActorType.__init__,_ActorType.__aenter__and_ActorType.initmethods and prepared a simple Actor:Execution:
This does not happen when using the Actor class without an instance, as shown below:
Output