MCPcopy
hub / github.com/scrapy/scrapy / _schedule_coro

Function _schedule_coro

scrapy/utils/defer.py:527–539  ·  view source on GitHub ↗

Schedule the coroutine as a task or a Deferred. This doesn't store the reference to the task/Deferred, so a better alternative is calling :func:`scrapy.utils.defer.deferred_from_coro`, keeping the result, and adding proper exception handling (e.g. errbacks) to it.

(coro: Coroutine[Any, Any, Any])

Source from the content-addressed store, hash-verified

525
526
527def _schedule_coro(coro: Coroutine[Any, Any, Any]) -> None:
528 """Schedule the coroutine as a task or a Deferred.
529
530 This doesn't store the reference to the task/Deferred, so a better
531 alternative is calling :func:`scrapy.utils.defer.deferred_from_coro`,
532 keeping the result, and adding proper exception handling (e.g. errbacks) to
533 it.
534 """
535 if not is_asyncio_available():
536 Deferred.fromCoroutine(coro)
537 return
538 loop = asyncio.get_event_loop()
539 loop.create_task(coro) # noqa: RUF006
540
541
542@overload

Callers 11

_open_spiderMethod · 0.90
scraped_dataMethod · 0.90
_init_with_reactorMethod · 0.90
_scrape_nextMethod · 0.90
handle_spider_errorMethod · 0.90
_process_start_nextMethod · 0.90
_spider_idleMethod · 0.90
_process_queueMethod · 0.90
_close_spiderMethod · 0.90
_check_limitMethod · 0.90

Calls 1

is_asyncio_availableFunction · 0.90

Tested by 1