Skip to content
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

Change TWISTED_REACTOR in the default template. #5679

Merged
merged 2 commits into from Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/topics/settings.rst
Expand Up @@ -1642,6 +1642,11 @@ install the default reactor defined by Twisted for the current platform. This
is to maintain backward compatibility and avoid possible problems caused by
using a non-default reactor.

.. versionchanged:: VERSION
The :command:`startproject` command now sets this setting to
``twisted.internet.asyncioreactor.AsyncioSelectorReactor`` in the generated
``settings.py`` file.

For additional information, see :doc:`core/howto/choosing-reactor`.


Expand Down
1 change: 1 addition & 0 deletions scrapy/templates/project/module/settings.py.tmpl
Expand Up @@ -89,3 +89,4 @@ ROBOTSTXT_OBEY = True

# Set settings whose default value is deprecated to a future-proof value
REQUEST_FINGERPRINTER_IMPLEMENTATION = 'VERSION'
TWISTED_REACTOR = 'twisted.internet.asyncioreactor.AsyncioSelectorReactor'
9 changes: 8 additions & 1 deletion tests/test_commands.py
Expand Up @@ -689,8 +689,15 @@ def test_asyncio_enabled_true(self):
])
self.assertIn("Using reactor: twisted.internet.asyncioreactor.AsyncioSelectorReactor", log)

def test_asyncio_enabled_false(self):
def test_asyncio_enabled_default(self):
log = self.get_log(self.debug_log_spider, args=[])
self.assertIn("Using reactor: twisted.internet.asyncioreactor.AsyncioSelectorReactor", log)

def test_asyncio_enabled_false(self):
log = self.get_log(self.debug_log_spider, args=[
'-s', 'TWISTED_REACTOR=twisted.internet.selectreactor.SelectReactor'
])
self.assertIn("Using reactor: twisted.internet.selectreactor.SelectReactor", log)
self.assertNotIn("Using reactor: twisted.internet.asyncioreactor.AsyncioSelectorReactor", log)

@mark.skipif(sys.implementation.name == 'pypy', reason='uvloop does not support pypy properly')
Expand Down