On Thu, 2006-08-17 at 04:15 +0200, Daniel Poelzleithner wrote: [...] > I think django should have a Lock class and maybe Semaphores, too, which > check which type of server the app is running and choose the best > locking method.
I think this is really beyond the scope of Django. If you need inter-process locking, it is going to be for specific circumstances (e.g. is it an exclusive lock, a counted lock, a read-write lock, a re-entrant lock, ...?) and it is more appropriate to pick a solution based on the surrounding infrastructure you have (web server + OS + process/thread structure). Otherwise we end up having to maintain something that is about as complex as the python threading + fcntl modules put together for all possible platforms. Asking the Django maintainers to shoulder the burden so that somebody with a precise requirement like that doesn't have to do a little bit of work for their own situation is probably too much. "Batteries included" can be taken too far: you already have the batteries in the Python libraries and should use them as appropriate. I'm not sure how you detect what mode you are running in for all the different web server configurations, either. For those who think this shouldn't be that hard, consider implementing a Semaphore-like class using filesystem behaviour in a secure and robust fashion. It is unbelievably hard. Compounded in difficulty by the fact that many systems only implement a portion of the POSIX interfaces, so you end up with a lot of non-portable, system-specific code. A simple exclusive lock are easy (os.mkdir() is the most portable way to do this that I know of, although there are still places it won't work perfectly), but it rapidly gets more fiddly once you go beyond that. All that being said, we take patches. So code something up and let's see how it goes. > Django already has a RWLock class under utils/sync.py, which is simply > not working on all servers. We need to document that more clearly. In core, it's only used for the in-process, multi-threaded local memory caching backend (the "locmem" cache), so it's working as advertised in that case. Users do need to be aware of the limitations there, though. Anything based on Python's threading module isn't going to be able to work cross-process. Cheers, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---