aio-libs / aiozmq

Asyncio (pep 3156) integration with ZeroMQ
aiozmq.readthedocs.org
BSD 2-Clause "Simplified" License
422 stars 56 forks source link

Are connections closed when they go out of scope ? #99

Closed stuaxo closed 7 years ago

stuaxo commented 7 years ago

In the following bit of code do I need to explicitly call .close(), or will it happen because player_client goes out of scope ?

            try:
                player_client = yield from aiozmq.rpc.connect_rpc(
                    connect="tcp://%s:%s" % ("0.0.0.0", self.local_player_port),
                    timeout=CLIENT_PLAYER_TIMEOUT)

                local_player.peer_token = peer_token
                yield from player_client.call.update_peer_token(self.local_player.token, peer_token)
            except asyncio.TimeoutError:
                # timeout TODO
                logger.error("Client > Player timeout")

        asyncio.ensure_future(call_update_peer_token())
asvetlov commented 7 years ago

You should close connections explicitly