Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

chore: utilizeensure_context decorator for Actor#400

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vdusek wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromadd-ensure-context

Conversation

vdusek
Copy link
Contributor

Utilizeensure_context decorator from Crawlee rather than callingraise_if_... method in the Actor class.

@vdusekvdusek added adhocAd-hoc unplanned task added during the sprint. debtCode quality improvement or decrease of technical debt. t-toolingIssues with this label are in the ownership of the tooling team. labelsFeb 13, 2025
@vdusekvdusek self-assigned thisFeb 13, 2025
@vdusekvdusek marked this pull request as ready for reviewFebruary 13, 2025 09:16
@vdusekvdusek marked this pull request as draftFebruary 13, 2025 09:17
@github-actionsgithub-actionsbot added the testedTemporary label used only programatically for some analytics. labelFeb 13, 2025
@vdusekvdusek marked this pull request as ready for reviewFebruary 13, 2025 09:25
Copy link
Contributor

@janbucharjanbuchar left a comment

Choose a reason for hiding this comment

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

I'm honestly not sure about this. It reduces some duplication, yes, but the error message will be pretty cryptic. It is fine for an internal helper in Crawlee, but here, it's very much user-facing. Maybe we could make a wrapper for the decorator?

@vdusek
Copy link
ContributorAuthor

Error message:

RuntimeError: The _ActorType is not active. Use it within the async context.

Whole traceback:

>>> asyncio.run(Actor.reboot())Traceback (most recent call last):  File "<python-input-5>", line 1, in <module>    asyncio.run(Actor.reboot())    ~~~~~~~~~~~^^^^^^^^^^^^^^^^  File "/usr/lib64/python3.13/asyncio/runners.py", line 195, in run    return runner.run(main)           ~~~~~~~~~~^^^^^^  File "/usr/lib64/python3.13/asyncio/runners.py", line 118, in run    return self._loop.run_until_complete(task)           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^  File "/usr/lib64/python3.13/asyncio/base_events.py", line 725, in run_until_complete    return future.result()           ~~~~~~~~~~~~~^^  File "/home/vdusek/Projects/apify-sdk-python/.venv/lib/python3.13/site-packages/crawlee/_utils/context.py", line 36, in async_wrapper    raise RuntimeError(f'The {self.__class__.__name__} is not active. Use it within the async context.')RuntimeError: The _ActorType is not active. Use it within the async context.

Is it that bad? We can wrap it of course.

@janbuchar
Copy link
Contributor

janbuchar commentedFeb 13, 2025
edited
Loading

Is it that bad? We can wrap it of course.

Well, leaking the existence of_ActorType is confusing by itself. Plus, the message should tell the user "Just useActor.init orasync with Actor" - many of them won't even know what a context manager is.

B4nan reacted with thumbs up emoji

Copy link
Contributor

@PijukatelPijukatel left a comment

Choose a reason for hiding this comment

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

I like this decorator, maybe we have to have custom error message in this case, but I think it makes the code more readable.

@vdusek
Copy link
ContributorAuthor

Yep, I will try to update the decorator to have a better error message there.

@janbucharjanbuchar self-requested a reviewMarch 24, 2025 14:09
Copy link
Contributor

@janbucharjanbuchar left a comment

Choose a reason for hiding this comment

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

Please wrap that error message 🙂

vdusek reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@janbucharjanbucharjanbuchar requested changes

@PijukatelPijukatelPijukatel approved these changes

Requested changes must be addressed to merge this pull request.

Assignees

@vdusekvdusek

Labels
adhocAd-hoc unplanned task added during the sprint.debtCode quality improvement or decrease of technical debt.t-toolingIssues with this label are in the ownership of the tooling team.testedTemporary label used only programatically for some analytics.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
@vdusek@janbuchar@Pijukatel

[8]ページ先頭

©2009-2025 Movatter.jp