Skip to content

BaseProxy: allow to specify custom connection #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2019
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