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]
)
| 232 | |
| 233 | |
| 234 | def 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 | |
| 254 | class CallLaterResult: |