channels_redis icon indicating copy to clipboard operation
channels_redis copied to clipboard

Doubt on the implementation of close_loop(self, loop)

Open tinylambda opened this issue 5 years ago • 0 comments

https://github.com/django/channels_redis/blob/0c27648b60a1918c867b96a5ad3f67ef58ccceda/channels_redis/core.py#L105

In the implementation of this method, it's annotation says "Close all connections owned by the pool on the given loop" and the method body is:

    async def close_loop(self, loop):
        """
        Close all connections owned by the pool on the given loop.
        """
        if loop in self.conn_map:
            for conn in self.conn_map[loop]:
                conn.close()
                await conn.wait_closed()
            del self.conn_map[loop]

        for k, v in self.in_use.items():
            if v is loop:
                self.in_use[k] = None

for every connection in self.conn_map[loop] here call conn.close() and await conn.wait_closed() to close the connections manually, and finally del self.conn_map[loop], that's fine.

but for the self.in_use dict, where its key is connection object and v is the loop object, here just set the value of the connection object to None, but not call k.close() and await k.wait_closed(). Is here we don't need to close it ?

tinylambda avatar Mar 28 '20 07:03 tinylambda