Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: Add RemainingTime option for timeout argument of Actor.call and Actor.start #473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 20, 2025

Conversation

Pijukatel
Copy link
Contributor

@Pijukatel Pijukatel commented May 16, 2025

Description

Added convenient way to start another Actor with reasonable timeout to prevent lingering actor runs after main actor shuts down.
Added test.

RemainingTime value of the timeout argument is not a default one and has to be explicitly passed by the user. Using this value will calculate remaining time of this actor run and pass it as a timeout to the actor that is being started.

Issues

@Pijukatel Pijukatel added enhancement New feature or request. t-tooling Issues with this label are in the ownership of the tooling team. labels May 16, 2025
@github-actions github-actions bot added this to the 114th sprint - Tooling team milestone May 16, 2025
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label May 16, 2025
@Pijukatel Pijukatel requested review from vdusek and janbuchar and removed request for vdusek May 16, 2025 11:52
if self.is_at_home() and self.configuration.timeout_at:
return self.configuration.timeout_at - datetime.now(tz=timezone.utc)

self.log.warning('Using `RemainingTime` argument for timeout outside of the Apify platform. Returning `None`')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be printed out if self.is_at_home() is True, but self.configuration.timeout_at is None? I assume that this is unlikely, but still.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanded the warning

async with Actor:
actor_input = (await Actor.get_input()) or {}
if actor_input.get('called_from_another_actor', False) is True:
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the Actor finishes immediately and you just check that the timeout was configured correctly? I agree that it's fine to trust the platform. Could you add a comment here that explains that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments

src/apify/_actor.py Outdated Show resolved Hide resolved
src/apify/_actor.py Outdated Show resolved Hide resolved
src/apify/_actor.py Outdated Show resolved Hide resolved
Co-authored-by: Vlada Dusek <v.dusek96@gmail.com>
@Pijukatel Pijukatel force-pushed the remaining-timeout branch from 30ad913 to 31da56f Compare May 20, 2025 08:05
@Pijukatel Pijukatel force-pushed the remaining-timeout branch from 31da56f to 05eed5f Compare May 20, 2025 08:13
Copy link
Contributor

@vdusek vdusek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Pijukatel Pijukatel merged commit ba7f757 into master May 20, 2025
27 checks passed
@Pijukatel Pijukatel deleted the remaining-timeout branch May 20, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add conveninece RemainingTime option for Actor.start and Actor.call
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.