On Mar 4, 2009, at 1:58 PM, kgs wrote:
Inside __call__ method after some processing we are in find_controller method - and here we are *accessing and modyfing* dictionary self.controller_classes. But this dictionary is shared between many threads, so is it thread safe?
Access to Python objects is thread-safe in that Python itself has a Global Interpreter Lock (GIL) that prevents say, two threads from updating the exact same key at the exact same time. The GIL locks on the dict access/setting.
The GIL does not generally lock on many operations that occur at the C layer, like I/O, and while waiting on database access.
Looking up Python GIL should provide quite a few threads about it. It's for this reason that to ensure you're effectively using a multi- core processor to its full potential, you should run a Pylons process for every core. This is what I do for all the sites I run.
Cheers, Ben
smime.p7s
Description: S/MIME cryptographic signature
