Hi,

For couple of last days I was creating simple WSGI app based on Paste
components. Pylons are also based on Paste, so  I started reading
Pylons sources to learn something new :)

I've found something that for me is strange, maybe because I don't
fully understand how threading  works in Python. As I correctly
uderstand PylonsApp object (from wsgiapp.py module) is created only
one for application (it is shared between all worker threads in WSGI
server like Paste#http) and its __call__ method is called from many
threads. Am I right?

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?

I could not find anywhere unambigous answer if accessing Python
primitives from many threads is safe or not - for me it looks that it
might be not safe (because modyfing/iterating/accessing e.g.
dictionary may result in context switches).

So if it would be not safe we need some RWLock here, right? I am
asking also because in my application I also want to store some
"global" data as dict (shared between all worker threads) and I am
wondering if I have to use locking primitives.

Thanks in advance for all explanations.

--
Cheers,
Kamil Gorlo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to