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

disconnect on exit very slow #297

Open
didacarbones opened this issue Oct 29, 2024 · 3 comments
Open

disconnect on exit very slow #297

didacarbones opened this issue Oct 29, 2024 · 3 comments

Comments

@didacarbones
Copy link

I am experiencing severe delays on the main python process exiting. I can take about 5 minutes to exit. I have to force it to exit by repeatedly sending SIGINT. I can see that the exception stacktrace printed shows that it is waiting on the disconnect request response here:

            iter_timeout = int(max(timeout - (time.time() - start_time), 1)) if timeout is not None else None
            if not request.response_event.wait(timeout=iter_timeout):
                value = request.message["message_id"].get_value()
                raise SMBException(
                    f"Connection timeout of {timeout} seconds exceeded while waiting for a message id {value} "
                    "response from the server"
                )

This piece of code is reached atexit after calling smbclient.reset_connection_cache. I have tried calling it myself, before exiting, or keeping a smaller connection cache as suggested in #176. I have only had success by copying the contents of reset_connection_cache over, and passing a timeout to the connection.disconnect call. I can create a PR, but I wanted to make an issue first, so we can start a discussion on whether this is a sensible thing to do. My suggestion is to add a disconnect timeout parameter in ClientConfig, and using that in reset_connection_cache. I would imagine a sensible default would be 3-5 seconds.

@jborean93
Copy link
Owner

I think adding an option to the ClientConfig makes sense to shorten the time It would be nice to find out why something is taking 5 minutes to disconnect though, maybe the default doesn't make too much sense and we should just leave the server to reap any outstanding connections and keep our tidy up to be around 1-5 seconds.

@didacarbones
Copy link
Author

Sounds good. Shall I make a PR, or is is something you'd want to tackle?

@jborean93
Copy link
Owner

If you feel up to doing it then that would be great. Otherwise I’ll get to it when I can find the time.

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

No branches or pull requests

2 participants