-
Notifications
You must be signed in to change notification settings - Fork 54
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
unify code that closes resources close()
#1273
Comments
you will broadly be better off with it's the last one that should result in no exceptions and not be cancellable, similar to how Regarding cancellation of closing, again, this is one of the few exceptions where you want to catch cancellederror and ignore it. A close should always be non-blocking, ie it should do whatever it can to release resources and clean up, but any "in-progress" work (pending writes etc) can get lost if someone chooses to perform an irregular close (ie not using the above forms of half-closing and waiting for a response) |
my recommendation is to avoid too many of these - they tend to hide an underlying design problem - ie if you have to catch lots of exceptions in close, you're likely doing something wrong elsewhere and should have been reporting those errors in another way. |
nim-libp2p
does not have standardized method of dealing with common patter of closing occupied resources: connections, streams, etc...this issue is opened with idea of coming up with approach for handling this common pattern. where some suggestion to begin with are in #1266 (comment) and code introduced in that PR.
agenda:
close
orcloseAndWait
? when should code do one and when another?close
propagates unnecessary exceptions - like closing already closed resources can sometime raise exception. and these situations it might be better just not to raise it - closing already closed should have no effectThe text was updated successfully, but these errors were encountered: