@@ -248,7 +248,6 @@ class Synapse(object):
248
248
authEndpoint: Location of authentication service
249
249
fileHandleEndpoint: Location of file service
250
250
portalEndpoint: Location of the website
251
- serviceTimeoutSeconds: Wait time before timeout (currently unused)
252
251
debug: Print debugging messages if True
253
252
skip_checks: Skip version and endpoint checks
254
253
configPath: Path to config File with setting for Synapse. Defaults to ~/.synapseConfig
@@ -281,6 +280,9 @@ class Synapse(object):
281
280
raised. These will be appended to the default `User-Agent` header that
282
281
already includes the version of this client that you are using, and the
283
282
HTTP library used to make the request.
283
+ timeout: The timeout in seconds for HTTP requests. The default is 70 seconds.
284
+ You may increase this if you are experiencing timeouts when interacting
285
+ with slow services.
284
286
285
287
Example: Getting started
286
288
Logging in to Synapse using an authToken
@@ -336,6 +338,7 @@ def __init__(
336
338
asyncio_event_loop : asyncio .AbstractEventLoop = None ,
337
339
cache_client : bool = True ,
338
340
user_agent : Union [str , List [str ]] = None ,
341
+ http_timeout_seconds : int = 70 ,
339
342
) -> "Synapse" :
340
343
"""
341
344
Initialize Synapse object
@@ -374,6 +377,9 @@ def __init__(
374
377
raised. These will be appended to the default `User-Agent` header that
375
378
already includes the version of this client that you are using, and the
376
379
HTTP library used to make the request.
380
+ http_timeout_seconds: The timeout in seconds for HTTP requests.
381
+ The default is 70 seconds. You may increase this if you are
382
+ experiencing timeouts when interacting with slow services.
377
383
378
384
Raises:
379
385
ValueError: Warn for non-boolean debug value.
@@ -391,7 +397,8 @@ def __init__(
391
397
else :
392
398
self ._requests_session_async_synapse = {}
393
399
394
- httpx_timeout = httpx .Timeout (70 , pool = None )
400
+ self ._http_timeout_seconds = http_timeout_seconds
401
+ httpx_timeout = httpx .Timeout (http_timeout_seconds , pool = None )
395
402
self ._requests_session_storage = requests_session_storage or httpx .Client (
396
403
timeout = httpx_timeout
397
404
)
@@ -505,7 +512,7 @@ async def close_connection() -> None:
505
512
await self ._requests_session_async_synapse [asyncio_event_loop ].aclose ()
506
513
del self ._requests_session_async_synapse [asyncio_event_loop ]
507
514
508
- httpx_timeout = httpx .Timeout (70 , pool = None )
515
+ httpx_timeout = httpx .Timeout (self . _http_timeout_seconds , pool = None )
509
516
self ._requests_session_async_synapse .update (
510
517
{
511
518
asyncio_event_loop : httpx .AsyncClient (
@@ -758,6 +765,7 @@ def setEndpoints(
758
765
endpoints [point ],
759
766
allow_redirects = False ,
760
767
headers = synapseclient .USER_AGENT ,
768
+ timeout = self ._http_timeout_seconds ,
761
769
),
762
770
verbose = self .debug ,
763
771
** STANDARD_RETRY_PARAMS ,
@@ -6216,12 +6224,14 @@ def _rest_call(
6216
6224
6217
6225
auth = kwargs .pop ("auth" , self .credentials )
6218
6226
requests_method_fn = getattr (requests_session , method )
6227
+ timeout = kwargs .pop ("timeout" , self ._http_timeout_seconds )
6219
6228
response = with_retry (
6220
6229
lambda : requests_method_fn (
6221
6230
uri ,
6222
6231
data = data ,
6223
6232
headers = headers ,
6224
6233
auth = auth ,
6234
+ timeout = timeout ,
6225
6235
** kwargs ,
6226
6236
),
6227
6237
verbose = self .debug ,
0 commit comments