Skip to content

fix: add a check thread before set add_signal_handler#1068

Merged
vdusek merged 1 commit into
apify:masterfrom
Mantisus:handle-not-main-threading
Mar 12, 2025
Merged

fix: add a check thread before set add_signal_handler#1068
vdusek merged 1 commit into
apify:masterfrom
Mantisus:handle-not-main-threading

Conversation

@Mantisus

@Mantisus Mantisus commented Mar 10, 2025

Copy link
Copy Markdown
Collaborator

Description

@Mantisus

Mantisus commented Mar 10, 2025

Copy link
Copy Markdown
Collaborator Author

The problem is reproduces in GCP Cloud Functions. Since under the hood they use Flask run via guvicorn

        File "/crawlee/crawlers/_basic/_basic_crawler.py", line 539, in run
          asyncio.get_running_loop().add_signal_handler(signal.SIGINT, sigint_handler)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/asyncio/unix_events.py", line 109, in add_signal_handler
          raise RuntimeError(str(exc))
      RuntimeError: set_wakeup_fd only works in main thread of the main interpreter

@Mantisus Mantisus requested a review from janbuchar March 10, 2025 16:29
@Mantisus Mantisus changed the title fix: add a check before set add_signal_handler fix: add a check thread before set add_signal_handler Mar 10, 2025
@Mantisus Mantisus self-assigned this Mar 10, 2025

@janbuchar janbuchar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Mantisus Mantisus requested a review from vdusek March 11, 2025 16:51

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@vdusek vdusek merged commit 6983bda into apify:master Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants