The example below shows the usage of lock command: def demo(host, user, names): With manager. Connect(host=host, port=22, username=user) as m: With m.locked(target='running'): for n in names: m.edit_config (target='running', config=template % n) The command "m.locked (target='running')" causes a lock to be acquired on the running datastore.