- Can we add a support for context manager so we can use 'with' statement to ensure every manager is closed properly.
- Need dunder __enter__ and __exit__ added to the manager class.
- This is meant for the service provider. Without a support for 'with' statement, we have to wrap the service provider in a try/finally block. Like this..
sp_instance = NetconfServiceProvider(address='1.1.1.1', port=830, username='cisco', password='cisco', protocol='ssh')
try:
do something
finally:
sp_instance.close()
- Many network engineers who may not necessarily have programming experience may forget to close the session, and that leaves netconf session opened on the router. If we do this enough we may exhaust session resources on the router/switch.
- Can we add the dunder enter/exit method on the provider class so we can do this ...
- with NetconfServiceProvider(....) as xr:
- do something.. and the exit method will always properly close the session.
Agree that this would be a good enhancement for the ServiceProvider classes. Feel free to raise an issue for this on github and we will address it Issues · CiscoDevNet/ydk-gen · GitHub
Comments
0 comments
Please sign in to leave a comment.