Skip to content

Commit 0daca28

Browse files
authored
refactor!: Remove wait_for_finish from Actor.start (#962)
## Description - Remove the `wait_for_finish` argument from `Actor.start()`. It contradicted the method's purpose: `Actor.start()` only starts the run without waiting for it to finish. The JS SDK does not expose it either. To wait for a run to finish, use `Actor.call()`. - Fix the `wait` docstrings of `Actor.call()` and `Actor.call_task()`, which described a `timedelta` as "maximum number of seconds". - Document the removal in the v4 upgrading guide.
1 parent 0dec508 commit 0daca28

2 files changed

Lines changed: 18 additions & 9 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+
### 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+
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: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,12 @@ async def start(
894894
memory_mbytes: int | None = None,
895895
timeout: timedelta | None | Literal['inherit'] = None,
896896
force_permission_level: ActorPermissionLevel | None = None,
897-
wait_for_finish: int | None = None,
898897
webhooks: list[Webhook] | None = None,
899898
) -> Run:
900899
"""Run an Actor on the Apify platform.
901900
902-
Unlike `Actor.call`, this method just starts the run without waiting for finish.
901+
Unlike `Actor.call`, this method just starts the run without waiting for finish. To wait for the run to
902+
finish, use `Actor.call` instead.
903903
904904
Args:
905905
actor_id: The ID of the Actor to be run.
@@ -918,8 +918,6 @@ async def start(
918918
to the time remaining from this Actor timeout.
919919
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
920920
with permissions configured in the Actor settings.
921-
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
922-
it is 0, the maximum value is 300.
923921
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
924922
the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed.
925923
If you already have a webhook set up for the Actor or task, you do not have to add it again here.
@@ -948,7 +946,6 @@ async def start(
948946
memory_mbytes=memory_mbytes,
949947
run_timeout=actor_start_timeout,
950948
force_permission_level=force_permission_level,
951-
wait_for_finish=wait_for_finish,
952949
webhooks=to_client_representations(webhooks),
953950
)
954951

@@ -1031,8 +1028,7 @@ async def call(
10311028
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
10321029
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
10331030
a webhook set up for the Actor, you do not have to add it again here.
1034-
wait: The maximum number of seconds the server waits for the run to finish. If not provided,
1035-
waits indefinitely.
1031+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
10361032
logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined
10371033
default logger will be used. Setting `None` will disable any log propagation. Passing custom logger
10381034
will redirect logs to the provided logger.
@@ -1109,8 +1105,7 @@ async def call_task(
11091105
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
11101106
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
11111107
a webhook set up for the Actor, you do not have to add it again here.
1112-
wait: The maximum number of seconds the server waits for the run to finish. If not provided, waits
1113-
indefinitely.
1108+
wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
11141109
11151110
Returns:
11161111
Info about the started Actor run.

0 commit comments

Comments
 (0)