@@ -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 ,
@@ -1445,17 +1453,26 @@ def _check_entity_restrictions(
1445
1453
Raises:
1446
1454
SynapseUnmetAccessRestrictions: Warning for unmet access requirements.
1447
1455
"""
1448
- restrictionInformation = bundle ["restrictionInformation" ]
1449
- if restrictionInformation ["hasUnmetAccessRequirement" ]:
1450
- warning_message = (
1451
- "\n This entity has access restrictions. Please visit the web page for this entity "
1452
- f'(syn.onweb("{ id_of (entity )} ")). Look for the "Access" label and the lock icon underneath '
1453
- 'the file name. Click "Request Access", and then review and fulfill the file '
1454
- "download requirement(s).\n "
1455
- )
1456
+ restriction_information = bundle .get ("restrictionInformation" , None )
1457
+ if restriction_information and restriction_information .get (
1458
+ "hasUnmetAccessRequirement" , None
1459
+ ):
1460
+ if not self .credentials or not self .credentials ._token :
1461
+ warning_message = (
1462
+ "You have not provided valid credentials for authentication with Synapse."
1463
+ " Please provide an authentication token and use `synapseclient.login()` before your next attempt."
1464
+ " See https://python-docs.synapse.org/tutorials/authentication/ for more information."
1465
+ )
1466
+ else :
1467
+ warning_message = (
1468
+ "\n This entity has access restrictions. Please visit the web page for this entity "
1469
+ f'(syn.onweb("{ id_of (entity )} ")). Look for the "Access" label and the lock icon underneath '
1470
+ 'the file name. Click "Request Access", and then review and fulfill the file '
1471
+ "download requirement(s).\n "
1472
+ )
1456
1473
if downloadFile and bundle .get ("entityType" ) not in ("project" , "folder" ):
1457
1474
raise SynapseUnmetAccessRestrictions (warning_message )
1458
- warnings . warn (warning_message )
1475
+ self . logger . warning (warning_message )
1459
1476
1460
1477
def _getFromFile (
1461
1478
self , filepath : str , limitSearch : str = None , md5 : str = None
@@ -6207,12 +6224,14 @@ def _rest_call(
6207
6224
6208
6225
auth = kwargs .pop ("auth" , self .credentials )
6209
6226
requests_method_fn = getattr (requests_session , method )
6227
+ timeout = kwargs .pop ("timeout" , self ._http_timeout_seconds )
6210
6228
response = with_retry (
6211
6229
lambda : requests_method_fn (
6212
6230
uri ,
6213
6231
data = data ,
6214
6232
headers = headers ,
6215
6233
auth = auth ,
6234
+ timeout = timeout ,
6216
6235
** kwargs ,
6217
6236
),
6218
6237
verbose = self .debug ,
0 commit comments