[link|http://www.python.org/doc/current/lib/rlock-objects.html|Locks]

You create a lock object for the thing you wish to lock (in this case, a dictionary). Anytime you wish to access the dictionary, you attempt to acquire the lock first. When you are done using it, you release the lock.

I would suggest wrapping the dictionary (and the lock behavior) in an object so you don't have lock code all over the place.