Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create new session if refresh is True #939

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hutch3232
Copy link
Contributor

@hutch3232 hutch3232 commented Feb 11, 2025

Copy link
Member

@martindurant martindurant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple of small comments on wording.

On the kwargs: this is probably a leftover from previous code. It could be removed, but let's not do that in this PR.

s3fs/core.py Outdated
Examples
--------
>>> s3 = S3FileSystem(profile="<profile name>") # doctest: +SKIP
>>> s3.set_session() # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is actually async, so you would only call it with await within a coroutine, as happens elsewhere in the class. The exact alias is _connect (with the underscore), whereas connect (without the underscore) is the blocking version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clarifications. I haven't directly worked with async before and overlooked that. Let me know if you have additional suggestions for my edits.

s3fs/core.py Outdated
@@ -480,9 +480,26 @@ def _prepare_config_kwargs(self):

async def set_session(self, refresh=False, kwargs={}):
"""Establish S3 connection object.

``connect`` is an alias of ``set_session``. This method called with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is called by any operation on an s3fs instance.

You might call this directly from async code, so that you can assign the client object to a local variable
(^ this is implied in the documentation on async, but should no longer be important for most people).

@martindurant
Copy link
Member

I suppose a test would be nice for completeness: call connect(), and assert that the ._s3 and .session attributes have both changed. I wonder if this will cause warnings that those resources weren't closed, or if garbage collection will take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants