dictionaries and threads
Paul Rubin
http
Wed Jun 1 23:20:30 EDT 2005
Gary Robinson <grobinson at goombah.com> writes:
> As far as I can tell, if the Python bytecodes that cause dictionary
> modifications are atomic, then there should be no problem. But I don't
> know that they are because I haven't looked at the bytecodes.
Depending on behavior like that is asking for trouble. If it doesn't
kill your app's performance, put some kind of locks around the
dictionary and/or direct all access to the directory through a single
thread. The favorite Python idiom for that seems to be the Queue
module; you'd set up a work queue and a result queue to communicate
with the thread controlling the dictionary.
If your app absolutely can't stand that, look to a more fundamental
solution, maybe something like POSH (poshmodule.sf.net).
More information about the Python-list
mailing list