Skip to content
This repository was archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Refactor explicit DEFAULT_HTTP_CLIENT_TIMEOUT_MS.
Browse files Browse the repository at this point in the history
Remove unsupported ssl_options to avoid mistake of supporting.
  • Loading branch information
keitheis committed Jun 30, 2016
1 parent 2d9bc02 commit aa3ca2b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions thriftpy/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@


HTTP_URI = '{scheme}://{host}:{port}{path}'
DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 30000 # 30 seconds


class TFileObjectTransport(TTransportBase):
Expand Down Expand Up @@ -107,7 +108,6 @@ def __init__(self,
processor,
server_address,
iprot_factory,
ssl_options=None,
server_class=http_server.HTTPServer):
"""Set up protocol factories and HTTP server.
See http.server for server_address.
Expand Down Expand Up @@ -265,7 +265,7 @@ def _f(*args, **kwargs):
def make_client(service, host, port, path='', scheme='http',
proto_factory=TBinaryProtocolFactory(),
trans_factory=TBufferedTransportFactory(),
timeout=4000):
timeout=DEFAULT_HTTP_CLIENT_TIMEOUT_MS):
uri = HTTP_URI.format(scheme=scheme, host=host, port=port, path=path)
http_socket = THttpClient(uri, timeout)
transport = trans_factory.get_transport(http_socket)
Expand All @@ -278,7 +278,7 @@ def make_client(service, host, port, path='', scheme='http',
def client_context(service, host, port, path='', scheme='http',
proto_factory=TBinaryProtocolFactory(),
trans_factory=TBufferedTransportFactory(),
timeout=4000):
timeout=DEFAULT_HTTP_CLIENT_TIMEOUT_MS):
uri = HTTP_URI.format(scheme=scheme, host=host, port=port, path=path)
http_socket = THttpClient(uri, timeout)
transport = trans_factory.get_transport(http_socket)
Expand All @@ -291,11 +291,8 @@ def client_context(service, host, port, path='', scheme='http',


def make_server(service, handler, host, port,
proto_factory=TBinaryProtocolFactory(),
ssl_options=None
):
proto_factory=TBinaryProtocolFactory()):
processor = TProcessor(service, handler)
server = THttpServer(processor, (host, port),
iprot_factory=proto_factory,
ssl_options=ssl_options)
iprot_factory=proto_factory)
return server

0 comments on commit aa3ca2b

Please sign in to comment.