Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 2.15 KB

File metadata and controls

42 lines (33 loc) · 2.15 KB
id convenience-methods
title Convenience methods
description Use high-level methods for running Actors, waiting for results, and accessing data.

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';

import ApiLink from '@site/src/components/ApiLink';

import CallAsyncExample from '!!raw-loader!./code/07_call_async.py'; import CallSyncExample from '!!raw-loader!./code/07_call_sync.py';

The Apify client provides several convenience methods to handle actions that the API alone cannot perform efficiently, such as waiting for an Actor run to finish without running into network timeouts. These methods simplify common tasks and enhance the usability of the client.

  • ActorClient.call - Starts an Actor and waits for it to finish, handling network timeouts internally. Waits indefinitely by default, or up to the specified wait_duration.
  • ActorClient.start - Starts an Actor and immediately returns the Run object without waiting for it to finish.
  • RunClient.wait_for_finish - Waits for an already-started run to reach a terminal status.

Additionally, storage-related resources offer flexible options for data retrieval:

  • Key-value store records can be retrieved as objects, buffers, or streams.
  • Dataset items can be fetched as individual objects, serialized data, or iterated asynchronously.
{CallAsyncExample} {CallSyncExample}

:::tip The call() method polls internally and may take a long time for long-running Actors. Use start() and wait_for_finish() separately if you need more control over the waiting behavior. :::