Skip to content

Commit 480e774

Browse files
committed
Merge #150: Make it possible to explicitly close RPC connection
1ea9661 make it possible to explicitly close connection (Simon Mulser) 4df1bbb fix PEP8 too many blank lines (Simon Mulser) Pull request description: So far it is not possible to close a connection. you need to hope that GC does it or access `__connection` over the `__dict__` variable. This PR let the proxy expose a proper `close()` function. Tree-SHA512: 721c4bd250549264ec54b3a2f8c333dcd55ed90cfc9ff7e8720c2243ada3639785889e52adc6a2fdf4b5c670bc54e3c127b57b04215cc119d419e79794107598
2 parents 12a1fe2 + 1ea9661 commit 480e774

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bitcoin/rpc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def __init__(self,
197197
self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port,
198198
timeout=timeout)
199199

200-
201200
def _call(self, service_name, *args):
202201
self.__id_count += 1
203202

@@ -226,7 +225,6 @@ def _call(self, service_name, *args):
226225
else:
227226
return response['result']
228227

229-
230228
def _batch(self, rpc_call_list):
231229
postdata = json.dumps(list(rpc_call_list))
232230

@@ -251,6 +249,10 @@ def _get_response(self):
251249
return json.loads(http_response.read().decode('utf8'),
252250
parse_float=decimal.Decimal)
253251

252+
def close(self):
253+
if self.__conn is not None:
254+
self.__conn.close()
255+
254256
def __del__(self):
255257
if self.__conn is not None:
256258
self.__conn.close()

0 commit comments

Comments
 (0)