Hi Antonis, On 2018-01-09 07:14, Antonis Christofides wrote:
Ah, OK, sorry I didn't read all the discussion. So I guess that if you keep that in a global variable, it won't work if your Django app is running in many processes. (Besides, global variables are rarely a good idea.)
I agree completely that global variables should be avoided. I find them to be even more problematic in a language like python where they could be instatiated by simply importing a file/module. That's probably OK for a simple value like an integer, but I prefer imports not to have too many side effects.
If I understand the problem correctly, what I would do would probably be to touch a file whenever I make a change and examine the file modification date each time—if it's more recent than last time I checked, the data has been modified. Another option is to use the cache. For example, use memcached and store some data in there. IIRC the cache is shared among all instances of Django.
That's not really solving my problem, but thanks for your input. What I need is a "global" python popen object from the subprocess module.
Someone helpfully suggested using a singleton for that. I really don't like singletons either, but this could actually be one of the few use cases where that would make sense, so I think that's what I'll be doing.
Kind regards, Kasper Laudrup -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6662fd12-af9f-0271-8bb7-4486e80faf90%40stacktrace.dk. For more options, visit https://groups.google.com/d/optout.