-
Notifications
You must be signed in to change notification settings - Fork 364
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
Add exception handling for SMBFileSystem init connection errors #1650
Add exception handling for SMBFileSystem init connection errors #1650
Conversation
fsspec/implementations/smb.py
Outdated
retried_errors.append(exc) | ||
|
||
if retry < self.register_session_retries - 1: | ||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May as well make the retry time configurable and ideally exponential, base * factor**retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is great idea. Should the exponential option be also configurable? To avoid confusing a user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to make the max time equal to the wait time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting idea, but not the way around it is is other implementations (example). At least, then I would call it "max_wait_time", but probably better to have "base_wait_time" and backoff factor.
Related to #1571
This PR implements exception handling for
SMBFileSystem._connect()
which brings changes to the current implementation:Retrying all other exceptions could be dropped in the future once all exceptions suited for retry are identified. Until then, we should probably not affect current behavior as much as we should.
Other feature proposed in this PR is raising latest exception after all retries are exhausted. This will at least inform a user about excepted issue. (related question is whether to implement ExceptionGroup to inform about all exceptions)
Additionally, an implementation for exponential wait time growth from 0 to requested time (included) is added.
The wait time is calculated using exponential function. For factor=1 all wait times will be equal to
register_session_retry_wait
. For any number of retries, the last wait time will be equal toregister_session_retry_wait
and for retries>1 the first wait time will be equal toregister_session_retry_wait / factor
.By default a factor is made 10 as most optimal (quick first attempts)