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
12 changes: 10 additions & 2 deletions react/render_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def __unicode__(self):


class RenderServer(object):
def render(self, path, props=None, to_static_markup=False, request_headers=None):
def render(
self, path, props=None, to_static_markup=False, request_headers=None,
timeout=None
):
url = conf.settings.RENDER_URL

if props is not None:
Expand All @@ -45,12 +48,17 @@ def render(self, path, props=None, to_static_markup=False, request_headers=None)
if request_headers is not None:
all_request_headers.update(request_headers)

# Add a send/receive timeout with the request if not specified
if not isinstance(timeout, (tuple, int, float)):
timeout = (5, 5)

try:
res = requests.post(
url,
data=serialized_options,
headers=all_request_headers,
params={'hash': options_hash}
params={'hash': options_hash},
timeout=timeout
)
except requests.ConnectionError:
raise RenderServerError('Could not connect to render server at {}'.format(url))
Expand Down