Skip to content

Conversation

@Mantisus
Copy link
Collaborator

Description

  • Sets WindowsSelectorEventLoopPolicy only for templates that use curl-impersonate, provided that playwright is not used. Since curl-impersonate does not support ProactorEventLoop used in Windows.

For all other cases, ProactorEventLoop is recommended for Windows.

Issues

@Mantisus Mantisus requested a review from Copilot May 21, 2025 11:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR scopes the WindowsSelectorEventLoopPolicy setup to only curl-impersonate projects that don’t include Playwright, preventing ProactorEventLoop issues on Windows while keeping default behavior elsewhere.

  • Wraps the import platform and event loop policy call in a cookiecutter condition for curl-impersonate without Playwright
  • Removes the unconditional policy application and old guidance comment
  • Inserts blank-line helpers around conditional blocks

@@ -1,12 +1,15 @@
import asyncio
# % if cookiecutter.http_client == 'curl-impersonate' and 'playwright' not in cookiecutter.crawler_type
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

Using # % to denote Jinja directives can be confusing—consider using {% if ... %}/{% endif %} so the templating syntax is more explicit and easier to maintain.

Copilot uses AI. Check for mistakes.
import platform

# % endif
{{ '' }}
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The {{ '' }} blank-line insertion may be unnecessary and could be replaced with a simpler newline in the template to improve readability.

Suggested change
{{ '' }}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using an empty string, ignored when creating a result

Comment on lines 10 to +11
if platform.system() == 'Windows':
# This mitigates a warning raised by curl-cffi. If you do not need to use curl-impersonate, you may remove this.
# This mitigates a warning raised by curl-cffi.
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The original guidance explaining how to remove this policy if not using curl-impersonate was removed—consider re-adding a brief note for users who may not need this workaround.

Copilot uses AI. Check for mistakes.
@Mantisus Mantisus requested review from janbuchar and vdusek May 21, 2025 11:56


if __name__ == '__main__':
# % if cookiecutter.http_client == 'curl-impersonate' and 'playwright' not in cookiecutter.crawler_type
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should print a warning in case playwright+curl-cffi is selected, something like "Hey, curl-cffi will complain about the event loop policy, but that won't work with playwright, so just ignore the warning"

@Mantisus Mantisus self-assigned this May 21, 2025
@janbuchar
Copy link
Collaborator

Did you have a chance to test this on Windows @Mantisus?

@Mantisus
Copy link
Collaborator Author

Did you have a chance to test this on Windows @Mantisus?

Yep 😊

Copy link
Collaborator

@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

@janbuchar janbuchar merged commit f3b839f into apify:master May 21, 2025
23 checks passed
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.

Default crawlee[cli] template project broken on Windows

3 participants