On Sun, 2009-02-15 at 23:50 +0200, makka...@gmail.com wrote: > On Sunday 15 February 2009 10:39:26 pm slav0nic wrote: > > if u need start new thread - it will be work, but for more "djngo way" > > use signals > > Well that is not what i'm concerned about, i asked if a view is accessed only > by a one client. I dont want 2 views to acces the same xml and have the > shared object in a inconsistent format. If the views are not threadsafe what > is the best way to modify shared file objects?
Views are just normal Python functions. They aren't intrinsicly thread safe or unsafe -- it's up to you to manage that. If you're writing data to disk, you will need to make sure that only one process at a time does the writing. File locking is a common approach there: before working on the file (reading or writing), the function should get a lock on the file in question to ensure only one accessor at a time. Alternatively, if there's only ever going to be one writer and many readers and you somehow know that two processes won't both try to write the file, you can create the file under a temporary name and then move it into the final name once it's finished. Move is an atomic operation (other processes will either see the final result of the move or see nothing) on any decent file system. Regards, 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---