python/cpython · error · TypeError
when cannot be None
Error message
when cannot be None
What it means
Error "when cannot be None" thrown in python/cpython.
Source
Thrown at Lib/asyncio/base_events.py:811
Any positional arguments after the callback will be passed to
the callback when it is called.
"""
if delay is None:
raise TypeError('delay must not be None')
timer = self.call_at(self.time() + delay, callback, *args,
context=context)
if timer._source_traceback:
del timer._source_traceback[-1]
return timer
def call_at(self, when, callback, *args, context=None):
"""Like call_later(), but uses an absolute time.
Absolute time corresponds to the event loop's time() method.
"""
if when is None:
raise TypeError("when cannot be None")
self._check_closed()
if self._debug:
self._check_thread()
self._check_callback(callback, 'call_at')
timer = events.TimerHandle(when, callback, args, self, context)
if timer._source_traceback:
del timer._source_traceback[-1]
heapq.heappush(self._scheduled, timer)
timer._scheduled = True
return timer
def call_soon(self, callback, *args, context=None):
"""Arrange for a callback to be called as soon as possible.
This operates as a FIFO queue: callbacks are called in the
order in which they are registered. Each callback will be
called exactly once.
View on GitHub (pinned to bc6749cc3b)
Solutions
- Pass an absolute time (e.g. loop.time() + delay) to loop.call_at(when, callback); compute the value instead of passing None.
When it happens
Trigger: Raised when call_at() is invoked with when=None.
Common situations: See trigger scenarios.
AI-assisted analysis of python/cpython@bc6749cc3b (2026-08-14).
Data as JSON: /api/errors/ee2df532dd9a1c72.
Report an issue: GitHub.