Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bitcoin/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def __init__(self,
service_url=None,
service_port=None,
btc_conf_file=None,
timeout=DEFAULT_HTTP_TIMEOUT):
timeout=DEFAULT_HTTP_TIMEOUT,
connection=None):

# Create a dummy connection early on so if __init__() fails prior to
# __conn being created __del__() can detect the condition and handle it
Expand Down Expand Up @@ -204,8 +205,11 @@ def __init__(self,
authpair = authpair.encode('utf8')
self.__auth_header = b"Basic " + base64.b64encode(authpair)

self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port,
timeout=timeout)
if connection:
self.__conn = connection
else:
self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port,
timeout=timeout)

def _call(self, service_name, *args):
self.__id_count += 1
Expand Down