Use dictionaries is thread-safe manner.
One of the changes in Python 3 was in the way that dictionaries are
accessed: the dict.iter{keys,items,values} methods were removed, and the
return type of dict.{keys,items,values} was changed from returning a
copy of the dictionary data as a list to returning an iterable view of
the dictionary data that is modified along with the dictionary. one of
the implications of this is that it is now impossible to create an
iterable representation of dictionary data that is safe from
modifications from other threads, because dictionaries (and now the
views into the dictionaries) cannot be modified during iteration and
list(x) works using iteration. Way to go, Python.
This is most visible in the threads module: sometimes wait_all() will
crash with "RuntimeError: dictionary changed size during iteration."
Fixed that and some other potential multi-threaded dictionary access in
threads, dnfpayload and xkl_wrapper through the use of more locks, and
added a bunch of comments where I needed to convince myself that the
dictionary access is thread safe.