Use autofunction for inthread, drop reactor implementation note

This commit is contained in:
Kelly Su 2026-08-10 13:21:16 -07:00
parent 8ea1ffe41c
commit 8263f5c705
1 changed files with 2 additions and 3 deletions

View File

@ -210,6 +210,7 @@ Scrapy from doing any other work while it runs. To avoid this, you can wrap
the blocking call with :func:`~scrapy.utils.decorators.inthread`, which runs
it in a separate thread and returns an awaitable with the result:
.. skip: next
.. code-block:: python
from scrapy.utils.decorators import inthread
@ -226,9 +227,7 @@ it in a separate thread and returns an awaitable with the result:
result = await blocking_call(response.url)
# ... use result to yield items and requests
:func:`~scrapy.utils.decorators.inthread` uses :func:`asyncio.to_thread` when
asyncio support is enabled, and Twisted's thread pool otherwise, so it works
regardless of which reactor your project uses.
.. autofunction:: scrapy.utils.decorators.inthread
Common use cases for asynchronous code include: