You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It looks like as of 5.10.0, SimpleClient supports __enter__/__exit__ for calling disconnect. This is nice for Pythonic code and ensuring disconnect gets called even upon Exception.
Describe the solution you'd like
Can we port this same capability to Client?
Describe alternatives you've considered
One can use a DIY contextlib.contextmanager for this:
I don't believe this is very useful on the event-based client, because it is event based, so the decision to disconnect is unlikely to be made in the main function. Normally the disconnection will be triggered inside an event handler, or remotely by the server.
Likewise, your claim that this can disconnect when there is an exception does not really seem very likely, since all the logic is in event handlers. An exception raised in an event handler would happen on a separate thread and would not interrupt the client nor the application.
Okay, I didn't realize Client was supposed to be event based. I follow what you're saying, thanks for the detailed explanation. I guess not having __enter__ and __exit__ implemented help enforce that usage pattern.
Is your feature request related to a problem? Please describe.
It looks like as of 5.10.0,
SimpleClient
supports__enter__
/__exit__
for callingdisconnect
. This is nice for Pythonic code and ensuringdisconnect
gets called even uponException
.Describe the solution you'd like
Can we port this same capability to
Client
?Describe alternatives you've considered
One can use a DIY
contextlib.contextmanager
for this:It would be nice if the source code for
Client
directly supported__enter__
/__exit__
though to avoid this extra code.Logs
N/a
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: