Create a connection to a Q process from python, then close it:
c = QConnection(host='localhost',port=5000)
c.open()
c.close()
On the Q process, inspect .z.W, the socket will still be open.
Issue: The file handle associated with the Reader object has not been closed. As is outlined here: https://docs.python.org/3.5/library/socket.html#socket.socket.close The file handle associated with the socket is not released until all file objects from makefile are closed.
Remediation step:
c._reader._stream.close()
Suggested change:
Move the creation of the file object to QConnection._init_socketand also ensure it is closed in QConnection.close
Steps for Reproduction:
Create a connection to a Q process from python, then close it:
On the Q process, inspect .z.W, the socket will still be open.
Issue: The file handle associated with the Reader object has not been closed. As is outlined here: https://docs.python.org/3.5/library/socket.html#socket.socket.close The file handle associated with the socket is not released until all file objects from makefile are closed.
Remediation step:
c._reader._stream.close()
Suggested change:
Move the creation of the file object to
QConnection._init_socket
and also ensure it is closed inQConnection.close
Version Used: Python 3.5.1 and QPython 1.2