code: async def _handle_container_timeout(self, container_id, timeout):
          
          try:
              docker_stats = await self._docker_interface.get_stats(container_id)
              source = AsyncIteratorWrapper(docker_stats)
              nano_timeout = timeout * (10 ** 9)
              async for upd in source:
                  if upd is None:
                      await self._kill_it_with_fire(container_id)
                  self._logger.debug("%i", upd['cpu_stats']['cpu_usage']['total_usage'])
                  if upd['cpu_stats']['cpu_usage']['total_usage'] > nano_timeout:
                      self._logger.info("Killing container %s as it used %i CPU seconds (max was %i)",
                                        container_id, int(upd['cpu_stats']['cpu_usage']['total_usage'] / (10 ** 9)), timeout)
                      await self._kill_it_with_fire(container_id)
                      return
          except asyncio.CancelledError:
              pass
          except:
              self._logger.exception("Exception in _handle_container_timeout")
docs: Check timeout with docker stats
          :param container_id:
          :param timeout: in seconds (cpu time)