On Jun 11, 6:38 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

[cut]

> > This is OK for most of the code but in my case it leads to a problem:
> > the third party app that is initialized in a global variable locks a
> > file, and tries to relock it again as the __import__ is recalled:
>
> Isn't this also problematic when multiple threads or processes import
> the same file, then? There would seem to be a number of Django server
> configurations (e.g. modpython and flup) where this won't work. How are
> you working around those?
>

It's ok for the threads, using locks, but not for the processes you
are right

> You could write a function that did each of your once-only things and
> then set up a condition (file lock or creating a directory, for example)
> to prevent them running again. However, graceful shutdown is then an
> issue -- it may not always happen, leaving the lock in place and
> preventing a successful restart. That's a general problem in these sort
> of cases though. It's why "shared nothing" is one of the goals for
> frameworks like Django. Synchronising non-idempotent setup and state
> across threads/processes/random restarts is hard.

Ok, well since my use case is to provide data to an indexer that has
to
have one and only one writer running on its side (eg. the singleton I
wanted
to create), I guess I can do the following  to avoid the lock
problem  :

1/ a small, separated application that has a working thread that
watches a table in the DB

2/ My Django app (no matter wich process if it has several, somehow)
that feed this table
   with data to be processed

(a producers-consumer pattern)

This would be safer on crashes I believe, and faster.

Maybe this pattern is already implemented in some Django package ?

Thanks for your help

Tarek


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to