apify-client-python
apify-client-python copied to clipboard
No Endpoint for RunsClient.abort()
I am trying to run an actor for multiple times. the problem is that I don't want the scrapper to run more than 60 seconds. if running abort the run and return dataset.
apify_client = ApifyClient(client_id)
task = apify_client.task(task_id)
start = time.time()
task.call(wait_secs = 30)
end = time.time()
print(f"Run finished in : {end - start}")
last_run = task.last_run(status='RUNNING' , origin = 'API')
aborted_info = last_run.abort()
The error message says there is no end-point for abort.
apify_client._errors.ApifyApiError: We have bad news: there is no API endpoint at this URL. Did you specify it correctly?
Hi @Hardik7843, thanks for the bug report, I was able to reproduce it and will take a look at this soon.
Hi @Hardik7843, I just want you to provide a temporary workaround until it's fixed.
from apify_client import ApifyClient
from apify_shared.consts import ActorJobStatus, MetaOrigin
TOKEN = 'apify_api_...'
TASK_ID = '...'
apify_client = ApifyClient(TOKEN)
# Call the task
task_client = apify_client.task(TASK_ID)
task_client.call(wait_secs=1)
# Get the info about last run
last_run = task_client.last_run(status=ActorJobStatus.RUNNING, origin=MetaOrigin.API)
last_run_info = last_run.get()
# And abort the last run
run_client = apify_client.run(last_run_info['id'])
aborted_info = run_client.abort()
print(f'aborted_info: {aborted_info}')
Hope it helps.
Closing as the issue was resolved in https://github.com/apify/apify-client-python/pull/192.
Check a new client release 1.7.0.