Skip to content

ZeroMQ broker shutdown leaves sockets and context open #706

Open

Description

@IlyaKhalafi

Taskiq version

Current master at f08a54a

Python version

Python 3.12.13

OS

Linux with PyZMQ 27.1.0

What happened?

ZeroMQBroker.shutdown unbinds the client endpoint but never closes the socket or its context. The resources remain open for both client and worker brokers. A shutdown hook or result backend failure also leaves them open.

The example below prints False False after shutdown. Both resources should be closed. The same broker should still support a later startup, as it does now.

Relevant log output

False False

Broker initialization code

import asyncio
from taskiq import ZeroMQBroker

async def main():
    broker = ZeroMQBroker(zmq_pub_host="inproc://shutdown-repro")
    try:
        await broker.startup()
        await broker.shutdown()
        print(broker.socket.closed, broker.context.closed)
    finally:
        broker.context.destroy(linger=0)

asyncio.run(main())

The final cleanup is included so the reproduction itself does not leave resources open. It is not part of the broker shutdown.

Six real-socket regression cases reproduce this across client and worker shutdown, including hook and backend failures. This is separate from #401 and the merged #511, which fixed binding and connection behavior but did not release these resources. The NNG proposals in #602 and #612 concern a different broker.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions