Skip to content

Commit a1e295b

Browse files
committed
refactor!: Rename wait_for_finish to wait in Actor.start
Unify the argument with Actor.call and Actor.call_task, which use wait: timedelta for the same concept. The value is now a timedelta instead of an int in seconds.
1 parent cfff7bb commit a1e295b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

docs/04_upgrading/upgrading_to_v4.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ The deprecated `latest_sdk_version`, `log_format`, and `standby_port` fields hav
6969
- In place of `standby_port`, use `web_server_port`.
7070
- `latest_sdk_version` and `log_format` don't have replacement. SDK version checking isn't supported for the Python SDK and the log format should be adjusted in code instead.
7171

72+
## `Actor.start``wait_for_finish` is now `wait`
73+
74+
The `wait_for_finish: int` argument of `Actor.start()` has been renamed to `wait: timedelta`, matching `Actor.call()` and `Actor.call_task()`. The behavior is unchanged: the server still waits at most the given time (capped at 300 seconds) before returning the run info.
75+
76+
```python
77+
from datetime import timedelta
78+
79+
# Before (v3)
80+
run = await Actor.start('my-actor-id', wait_for_finish=60)
81+
82+
# After (v4)
83+
run = await Actor.start('my-actor-id', wait=timedelta(seconds=60))
84+
```
85+
7286
## Built on `apify-client` v3
7387

7488
The SDK is now built on [`apify-client`](https://docs.apify.com/api/client/python) v3 and no longer depends on `apify-shared`. The sections below cover the user-visible consequences; see the client's [Upgrading to v3](https://docs.apify.com/api/client/python/docs/upgrading/upgrading-to-v3) guide for the full list of changes in the client itself.

src/apify/_actor.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ async def start(
889889
memory_mbytes: int | None = None,
890890
timeout: timedelta | None | Literal['inherit'] = None,
891891
force_permission_level: ActorPermissionLevel | None = None,
892-
wait_for_finish: int | None = None,
893892
webhooks: list[Webhook] | None = None,
893+
wait: timedelta | None = None,
894894
) -> Run:
895895
"""Run an Actor on the Apify platform.
896896
@@ -913,11 +913,11 @@ async def start(
913913
to the time remaining from this Actor timeout.
914914
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
915915
with permissions configured in the Actor settings.
916-
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
917-
it is 0, the maximum value is 300.
918916
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
919917
the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed.
920918
If you already have a webhook set up for the Actor or task, you do not have to add it again here.
919+
wait: The maximum time the server waits for the run to finish. By default, it does not wait at all.
920+
The maximum value is 300 seconds.
921921
922922
Returns:
923923
Info about the started Actor run
@@ -943,7 +943,7 @@ async def start(
943943
memory_mbytes=memory_mbytes,
944944
run_timeout=actor_start_timeout,
945945
force_permission_level=force_permission_level,
946-
wait_for_finish=wait_for_finish,
946+
wait_for_finish=int(wait.total_seconds()) if wait is not None else None,
947947
webhooks=to_client_representations(webhooks),
948948
)
949949

@@ -1026,8 +1026,7 @@ async def call(
10261026
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
10271027
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
10281028
a webhook set up for the Actor, you do not have to add it again here.
1029-
wait: The maximum number of seconds the server waits for the run to finish. If not provided,
1030-
waits indefinitely.
1029+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
10311030
logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined
10321031
default logger will be used. Setting `None` will disable any log propagation. Passing custom logger
10331032
will redirect logs to the provided logger.
@@ -1104,8 +1103,7 @@ async def call_task(
11041103
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
11051104
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
11061105
a webhook set up for the Actor, you do not have to add it again here.
1107-
wait: The maximum number of seconds the server waits for the run to finish. If not provided, waits
1108-
indefinitely.
1106+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
11091107
11101108
Returns:
11111109
Info about the started Actor run.

0 commit comments

Comments
 (0)