fix: set `WindowsSelectorEventLoopPolicy` only for curl-impersonate template without `playwright` by Mantisus · Pull Request #1209 · apify/crawlee-python
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 platformand 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 | |||
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 | ||
| {{ '' }} |
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.
Copilot uses AI. Check for mistakes.
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. |
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.