code: def spin(self, timeout=None):
          
          if timeout != 0:
              deadline = (time.monotonic() + timeout) if timeout is not None else sys.float_info.max
  
              def execute_once():
                  next_event_at = self._poll_scheduler_and_get_next_deadline()
                  if next_event_at is None:
                      next_event_at = sys.float_info.max
  
                  read_timeout = min(next_event_at, deadline) - time.monotonic()
                  read_timeout = max(read_timeout, 0)
                  read_timeout = min(read_timeout, 1)
  
                  frame = self._can_driver.receive(read_timeout)
                  if frame:
                      self._recv_frame(frame)
  
              execute_once()
              while time.monotonic() < deadline:
                  execute_once()
          else:
              while True:
                  frame = self._can_driver.receive(0)
                  if frame:
                      self._recv_frame(frame)
                  else:
                      break
              self._poll_scheduler_and_get_next_deadline()
docs: Runs background processes until timeout expires.
          Note that all processing is implemented in one thread.
          :param timeout: The method will return once this amount of time expires.
                          If None, the method will never return.
                          If zero, the method will handle only those events that are ready, then return immediately.