-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
skip the broker check-in part of the context manager #196
Conversation
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'm not sure this should be specified on the class level, since it may be too broad. However, we can discuss intended uses and implementation in chat. This may ultimately be the least clumsy way of adding the skip functionality.
49af723
to
53a5031
Compare
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.
ACK with minor comment !
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.
One key part of this is allowing the behavior only when in the context manager. This implementation would also disallow checkins outside of the context manager.
You'll need to add an argument to checkin like in_context=True
and checking for that before the list comprehension filtering no_checkin hosts
if in_context:
do your comprehension filter
404264e
to
bb1183a
Compare
Okay, understood. I've added an additional layer of security to the check-in process. |
bb1183a
to
ed5918d
Compare
Description
This PR adds a new optional parameter to the Broker class,
skip_checkin,
which can be set toTrue
when instantiating the class to skip the check-in step when exiting the context.If
skip_checkin
is not set or is set to False, the__exit__
method will proceed with the normal check-in process, which includes attempting to perform a teardown on each host in the_hosts
list and calling thecheckin
method to perform the final check-in step.This change is useful when the
Broker
instance is being used in a context where a check-in is not necessary or desired, such as when performing read-only operations on remote servers.