Caching OIDs for PySNMP (and other bits of trivia...)


So today I completed the alterations to PySNMP to allow it to cache the BER encoding of OIDs. Then it took a couple of hours to fix all the stupid problems that arose. The most annoying was the stupid problems where diff produced garbage patches because one set of files had DOS line-endings and the other had Linux line-endings.

Yesterday was largely a write-off. I made the first of the performance optimisations live, then about an hour later all heck broke loose. Turns out that deep within TwistedSNMP I'd decided to get the message ID for use as a dispatching key by doing request['pdu'][pdutype]['request_id']. That would be fine, except that what was returned was not the ID, it was the holder for the ID. With the caching, it was always the same object. No problem if there's only one message "live" at any given time, but when the whole system started pinging and the chances of having multiple live queries rose, things went to heck.

You see, the key object had changed its hash value after being inserted in the dispatching dictionary. The result was that even the "failure" case would never find the deferred object it was supposed to fire. Seriously annoying. It took forever to track that down, and in the end it was just the lack of a ".get()" call.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.