Description
Situation:
I have a single pyroute2 NDB object that's shared between threads. Each thread queries the ndb.neighbours
table to find the IP of a host with a particular MAC address (or vice versa). Different threads sometimes run concurrently.
Problem:
Directly after a query is executed, a cache cleaning operation takes place - per https://github.com/svinota/pyroute2/blob/0.5.9/pyroute2/ndb/main.py#L322. Occasionally two or more threads will attempt to simultaneously remove the same cache key. The first thread succeeds, but others will throw a KeyError exception, since the cache entry they are trying to remove no longer exists.
Potential solution:
While I'm not very familiar with the workings of the NDB cache, a simple/harmless solution in this case would probably be to catch and ignore a KeyError exception on a cache deletion operation. Not sure if there are wider implications for the thread-safety of NDB though.
I can throw together some reproducer code if helpful, though I hope the issue I'm describing should be fairly clear.
Activity