Requests sent with the -callback
argument specified are sent asynchronously. That is, the API call returns immediately with a unique identifier for the request, rather than waiting for a timeout or response from the agent. The callback command is invoked when a a timeout or response is received and Tcl reaches the event in its event loop.
Sometimes it is necessary to wait for one request to finish before continuing with another (for example, when doing a get-next walk of the OID tree, you don't know what OID to use in the next request until a response is received to the previous request). If you are using asynchronous requests, you can use the wait
command to pause a script while waiting for a pending request and allow other events to be processed.
% snmpcmd wait ?id?
snmpcmd
id
If no id
argument is specified, this command will wait for all pending requests to be processed, and will return only when the request queue is empty. If an id
is specified, then it will return only when that request has timed out or received a response. The command returns immediately if id
doesn't correspond to any pending request.
% snmplib wait [snmplib next -callback my_callback 0.0]