MCPcopy
hub / github.com/scrapy/scrapy / call_later

Function call_later

scrapy/utils/asyncio.py:234–251  ·  view source on GitHub ↗

Schedule a function to be called after a delay. This uses either :meth:`asyncio.loop.call_later` or :meth:`reactor.callLater() <twisted.internet.base.ReactorBase.callLater>`, depending on whether asyncio support is available. .. versionadded:: 2.14.0

(
    delay: float, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]
)

Source from the content-addressed store, hash-verified

232
233
234def call_later(
235 delay: float, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]
236) -> CallLaterResult:
237 """Schedule a function to be called after a delay.
238
239 This uses either :meth:`asyncio.loop.call_later` or
240 :meth:`reactor.callLater() <twisted.internet.base.ReactorBase.callLater>`,
241 depending on whether asyncio support is available.
242
243 .. versionadded:: 2.14.0
244 """
245 if is_asyncio_available():
246 loop = asyncio.get_event_loop()
247 return CallLaterResult.from_asyncio(loop.call_later(delay, func, *args))
248
249 from twisted.internet import reactor
250
251 return CallLaterResult.from_twisted(reactor.callLater(delay, func, *args))
252
253
254class CallLaterResult:

Callers 14

scheduleMethod · 0.90
__call__Method · 0.90
_process_queueMethod · 0.90
spider_openedMethod · 0.90
persist_fileMethod · 0.90
ok_handlerMethod · 0.90
ok_handlerMethod · 0.90
return_responseMethod · 0.90
return_failureMethod · 0.90
ignore_requestMethod · 0.90

Calls 3

is_asyncio_availableFunction · 0.85
from_asyncioMethod · 0.80
from_twistedMethod · 0.80

Tested by 9

persist_fileMethod · 0.72
ok_handlerMethod · 0.72
ok_handlerMethod · 0.72
return_responseMethod · 0.72
return_failureMethod · 0.72
ignore_requestMethod · 0.72
process_itemMethod · 0.72
startMethod · 0.72