Skip to content

Commit 7832323

Browse files
committed
refactor!: Remove wait_for_finish from Actor.start
The argument contradicted the purpose of Actor.start, which only starts the run without waiting for it to finish, and the JS SDK does not expose it either. To wait for a run to finish, use Actor.call. The raw waitForFinish server param is still reachable via the underlying client.
1 parent cfff7bb commit 7832323

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

docs/04_upgrading/upgrading_to_v4.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ 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+
### `wait_for_finish` argument of `Actor.start`
73+
74+
The `wait_for_finish` argument of `Actor.start()` has been removed. It contradicted the purpose of `Actor.start()`, which only starts the run without waiting for it to finish. The JS SDK does not expose it on `Actor.start()` either. To wait for a run to finish, use `Actor.call()`.
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.call('my-actor-id', wait=timedelta(seconds=60))
84+
```
85+
86+
If you need the raw server-side `waitForFinish` behavior (return the run after the server waits up to N seconds, without polling to completion), call the underlying client directly:
87+
88+
```python
89+
run = await Actor.apify_client.actor('my-actor-id').start(wait_for_finish=60)
90+
```
91+
7292
## Built on `apify-client` v3
7393

7494
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: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -889,12 +889,12 @@ 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,
894893
) -> Run:
895894
"""Run an Actor on the Apify platform.
896895
897-
Unlike `Actor.call`, this method just starts the run without waiting for finish.
896+
Unlike `Actor.call`, this method just starts the run without waiting for finish. To wait for the run to
897+
finish, use `Actor.call` instead.
898898
899899
Args:
900900
actor_id: The ID of the Actor to be run.
@@ -913,8 +913,6 @@ 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.
@@ -943,7 +941,6 @@ async def start(
943941
memory_mbytes=memory_mbytes,
944942
run_timeout=actor_start_timeout,
945943
force_permission_level=force_permission_level,
946-
wait_for_finish=wait_for_finish,
947944
webhooks=to_client_representations(webhooks),
948945
)
949946

@@ -1026,8 +1023,7 @@ async def call(
10261023
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
10271024
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
10281025
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.
1026+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
10311027
logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined
10321028
default logger will be used. Setting `None` will disable any log propagation. Passing custom logger
10331029
will redirect logs to the provided logger.
@@ -1104,8 +1100,7 @@ async def call_task(
11041100
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
11051101
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
11061102
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.
1103+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
11091104
11101105
Returns:
11111106
Info about the started Actor run.

0 commit comments

Comments
 (0)