pika/pika · error · RuntimeError

IOLoop is not reentrant and is already running

Error message

IOLoop is not reentrant and is already running

What it means

Error "IOLoop is not reentrant and is already running" thrown in pika/pika.

Source

Thrown at pika/adapters/select_connection.py:851

        for fileno, events in fd_to_events.items():
            self._register_fd(fileno, events)

    def deactivate_poller(self) -> None:
        """Deactivate the poller."""
        self._uninit_poller()

    def start(self) -> None:
        """
        Start the main poller loop.

        It will loop until requested to exit. This method is not reentrant and will raise an error
        if called recursively (pika/pika#1095)

        :raises: RuntimeError
        """
        if self._running:
            raise RuntimeError('IOLoop is not reentrant and is already running')

        LOGGER.debug('Entering IOLoop')
        self._running = True
        self.activate_poller()

        try:
            # Run event loop
            while not self._stopping:
                self.poll()
                self._process_timeouts()
        finally:
            try:
                LOGGER.debug('Deactivating poller')
                self.deactivate_poller()
            finally:
                self._stopping = False
                self._running = False

View on GitHub (pinned to 295ad9e579)

When it happens

Trigger: Thrown at pika/adapters/select_connection.py:851 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pika/pika@295ad9e579 (2026-08-04). Data as JSON: /data/errors/3d14617a8b6027dd.json. Report an issue: GitHub.