Skip to content

Commit ecd6bd0

Browse files
committed
Fix: QConnection.close() frees linked file object
1 parent 432c838 commit ecd6bd0

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
------------------------------------------------------------------------------
2+
qPython 1.2.1 [2016.03.29]
3+
------------------------------------------------------------------------------
4+
5+
- Fix: QConnection.close() frees linked file object
6+
17
------------------------------------------------------------------------------
28
qPython 1.2.0 [2016.01.22]
39
------------------------------------------------------------------------------

qpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
__all__ = ['qconnection', 'qtype', 'qtemporal', 'qcollection']
1818

1919

20-
__version__ = '1.2.0'
20+
__version__ = '1.2.1'
2121

2222

2323

qpython/qconnection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __init__(self, host, port, username = None, password = None, timeout = None,
8585
self.password = password
8686

8787
self._connection = None
88+
self._connection_file = None
8889
self._protocol_version = None
8990

9091
self.timeout = timeout
@@ -143,7 +144,7 @@ def open(self):
143144
self._initialize()
144145

145146
self._writer = self._writer_class(self._connection, protocol_version = self._protocol_version, encoding = self._encoding)
146-
self._reader = self._reader_class(self._connection.makefile('b'), encoding = self._encoding)
147+
self._reader = self._reader_class(self._connection_file, encoding = self._encoding)
147148

148149

149150
def _init_socket(self):
@@ -152,14 +153,18 @@ def _init_socket(self):
152153
self._connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
153154
self._connection.connect((self.host, self.port))
154155
self._connection.settimeout(self.timeout)
156+
self._connection_file = self._connection.makefile('b')
155157
except:
156158
self._connection = None
159+
self._connection_file = None
157160
raise
158161

159162

160163
def close(self):
161164
'''Closes connection with the q service.'''
162165
if self._connection:
166+
self._connection_file.close()
167+
self._connection_file = None
163168
self._connection.close()
164169
self._connection = None
165170

0 commit comments

Comments
 (0)