Batch Operations
The batch operate SDK helpers allow you to efficiently process multiple URLs in parallel while managing browser sessions and windows automatically. These helpers automatically manage the lifecycle of browser sessions and windows, handling creation and cleanup behind the scenes so you can focus on your own application logic.
This guide explains how to use these helpers which are available in both the Node.js and Python Airtop SDKs.
Python SDK
Note that batch operations are currently only supported by the AsyncAirtop
client.
Basic Usage
Advanced Features
Error Handling
By default, the Batch Operate helpers will not automatically retry failed operations. However, you can implement this or other custom error handling by providing an on_error
callback.
Session Configuration
You can customize the session configuration for all sessions created during the batch operation.
Note that the persistProfile
option is not supported for batch operations. Instead, we recommend handling operations that require a persistent profile in a separate operation and then using that profile id in the session configuration for batch operations.
Halting Operations
You can stop the batch processing at any point by returning should_halt_batch=True
:
Controlling Concurrency
Note: We recommend keeping
max_windows_per_session=1
(the default) for optimal stability and performance. While you can experiment with multiple windows per session, single-window sessions are generally more reliable and easier to manage. Increasemax_concurrent_sessions
instead if you need more parallelization.
You can control the number of concurrent sessions and windows per session:
Dynamic URL Addition
Your operation can discover and add new URLs to process during execution. The original batch_operate call will not complete until all operations have completed, including the new additions.
Node.js SDK
Basic Usage
Advanced Features
Error Handling
By default, the Batch Operate helpers will not automatically retry failed operations. However, you can implement this or other custom error handling by providing an onError
callback.
Session Configuration
You can customize the session configuration for all sessions created during the batch operation.
Note that the persistProfile
option is not supported for batch operations. Instead, we recommend handling operations that require a persistent profile in a separate operation and then using that profile id in the session configuration for batch operations.
Halting Operations
You can stop the batch processing at any point by returning shouldHaltBatch: true
:
Controlling Concurrency
Note: We recommend keeping
maxWindowsPerSession=1
(the default) for optimal stability and performance. While you can experiment with multiple windows per session, single-window sessions are generally more reliable and easier to manage. IncreasemaxConcurrentSessions
instead if you need more parallelization.
You can control the number of concurrent sessions and windows per session:
Dynamic URL Addition
Your operation can discover and add new URLs to process during execution. The original batchOperate call will not complete until all operations have completed, including the new additions.