exxeleron / qPython

interprocess communication between Python and kdb+
http://www.devnet.de
Apache License 2.0
152 stars 89 forks source link

Closing a QConnection does not free the system resource #36

Closed nugend closed 8 years ago

nugend commented 8 years ago

Steps for Reproduction:

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

Version Used: Python 3.5.1 and QPython 1.2

maciejlach commented 8 years ago

@nugend Thank you for reporting and suggesting the changes.

I've created a pull request which addresses the issue (#37).

@exxeleron/core can you verify and integrate?