MCPcopy
hub / github.com/scrapy/scrapy / _defer_sleep_async

Function _defer_sleep_async

scrapy/utils/defer.py:89–100  ·  view source on GitHub ↗

Delay by _DEFER_DELAY so reactor has a chance to go through readers and writers before attending pending delayed calls, so do not set delay to zero.

()

Source from the content-addressed store, hash-verified

87
88
89async def _defer_sleep_async() -> None:
90 """Delay by _DEFER_DELAY so reactor has a chance to go through readers and writers
91 before attending pending delayed calls, so do not set delay to zero.
92 """
93 if is_asyncio_available():
94 await asyncio.sleep(_DEFER_DELAY)
95 else:
96 from twisted.internet import reactor
97
98 d: Deferred[None] = Deferred()
99 reactor.callLater(_DEFER_DELAY, d.callback, None)
100 await d
101
102
103def defer_result(result: Any) -> Deferred[Any]: # pragma: no cover

Callers 6

call_spider_asyncMethod · 0.90
scrape_response_asyncMethod · 0.90
download_asyncMethod · 0.90
_downloadMethod · 0.90
_process_requestMethod · 0.90
rsp1_funcMethod · 0.90

Calls 1

is_asyncio_availableFunction · 0.90

Tested by 1

rsp1_funcMethod · 0.72