-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow parallel read/write over the same netmiko session #407
Conversation
@mirceaulinic We will need to lock the direct read here also Also, I think we should make the time.sleep longer than 10 mS. Screen scraping happens much more on the 3-10 second time frame so pointless to check every 10 mS. At a minimum this should be 50mS. I also think the timeout for acquiring the lock will need to be longer than 8 second. Currently using the timeout which is set to 8 second. We need to figure out how to handle this as I am currently using timeout mostly as a read operation timeout. NAPALM also sets this timeout (at least in napalm-ios to 60 seconds) which is not a very good choice given how I am using it. So we need to work out what is logical here (i.e. given how it is used in Netmiko, NAPALM-ios, and this locking use). |
Yes, I have also thought about that. Perhaps we could introduce a separate timeout value, e.g. |
How about we add a new argument to
Then map the lock timeout to this. I also think (ultimately) we should map the NAPALM argument to this (and not the current timeout). |
Hi @ktbyers - I have introduced the new |
Ref: napalm-automation/napalm-ios#120
With these changes, the library will be able to handle parallel read / write operations independently over the same SSH / Telnet session. However, the limitation will be that in case there's a high number of concomitant commands,
NetMikoTimeoutException
is raised as there's no mechanism to uniquely identify each request. Basically parallel requests are queued and served sequentially when the channel is again ready.Commands executed over a different SSH session would not be affected by this, being handled in a separate netmiko instance.
The end user, or the developer should not see any change, and should not make any changes to their code.
I have tested this on a couple of Cisco 2811s using the napalm-ios driver and seems to work fine.
I have moved the logic from
write_channel
andread_channel
into_ write_channel
and_ read_channel
helpers; the public methods call the corresponding helpers and will unlock the channel before returning. So in case there's any exception it will be also forwarded and the channel is unlocked before returning. @ktbyers please let me know if this hierarchical change would be too much, or we should simply move everything fromread_channel
andwrite_channel
directly under the try-finally block?