@@ -480,9 +480,30 @@ def _prepare_config_kwargs(self):
480480
481481 async def set_session (self , refresh = False , kwargs = {}):
482482 """Establish S3 connection object.
483+
484+ This async method is called by any operation on an ``S3FileSystem`` instance.
485+ The ``refresh=True`` argument is useful if new credentials have been created
486+ and the instance needs to be reestablished. ``connect`` is a blocking
487+ version of ``set_session``.
488+
489+ Parameters
490+ ----------
491+ refresh : bool (False)
492+ If True, create a new session even if one already exists.
493+ kwargs : dict
494+ Currently unused.
495+
483496 Returns
484497 -------
485498 Session to be closed later with await .close()
499+
500+ Examples
501+ --------
502+ >>> s3 = S3FileSystem(profile="<profile name>") # doctest: +SKIP
503+ # use in an async coroutine to assign the client object to a local variable
504+ >>> await s3.set_session() # doctest: +SKIP
505+ # blocking version of set_session
506+ >>> s3.connect(refresh=True) # doctest: +SKIP
486507 """
487508 if self ._s3 is not None and not refresh :
488509 return self ._s3
@@ -522,7 +543,7 @@ async def set_session(self, refresh=False, kwargs={}):
522543 config_kwargs ["signature_version" ] = UNSIGNED
523544
524545 conf = AioConfig (** config_kwargs )
525- if self .session is None :
546+ if self .session is None or refresh :
526547 self .session = aiobotocore .session .AioSession (** self .kwargs )
527548
528549 for parameters in (config_kwargs , self .kwargs , init_kwargs , client_kwargs ):
0 commit comments