Skip to content

Commit 8b79591

Browse files
WillSewelldamdo
authored andcommitted
Pass kwarg options to HTTPRequest instead of AsyncHTTPClient
We shouldn't be passing these options to the AsyncHTTPClient. The docs state: > Unless force_instance=True is used, no arguments should be passed > to the AsyncHTTPClient constructor https://www.tornadoweb.org/en/stable/httpclient.html?highlight=AsyncHTTPClient#tornado.httpclient.AsyncHTTPClient The options instead should be set on the HTTPRequest: https://www.tornadoweb.org/en/branch5.1/httpclient.html#tornado.httpclient.HTTPRequest This is consistent with how options are passed to the requests backend.
1 parent 84c46d0 commit 8b79591

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pusher/tornado.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
class TornadoBackend(object):
1919
"""Adapter for the tornado.httpclient module.
2020
21-
:param client: pusher.Client object
22-
:param kwargs: options for the httpclient.HTTPClient constructor
21+
:param client: pusher.Client object
22+
:param options: options for the httpclient.HTTPClient constructor
2323
"""
24-
def __init__(self, client, **kwargs):
24+
def __init__(self, client, **options):
2525
self.client = client
26-
self.http = tornado.httpclient.AsyncHTTPClient(**kwargs)
26+
self.options = options
27+
self.http = tornado.httpclient.AsyncHTTPClient()
2728

2829

2930
def send_request(self, request):
@@ -43,8 +44,12 @@ def process_response_future(response):
4344
future.set_result(process_response(code, body))
4445

4546
request = tornado.httpclient.HTTPRequest(
46-
request.url, method=method, body=data, headers=headers,
47-
request_timeout=self.client.timeout)
47+
request.url,
48+
method=method,
49+
body=data,
50+
headers=headers,
51+
request_timeout=self.client.timeout,
52+
**self.options)
4853

4954
response_future = self.http.fetch(request, raise_error=False)
5055
response_future.add_done_callback(process_response_future)

0 commit comments

Comments
 (0)