I use flup as fastcgi server for Django.
Please explain to me how can I use singleton? I'm not sure I understand threading models for Flup well.
I use flup as fastcgi server for Django.
Please explain to me how can I use singleton? I'm not sure I understand threading models for Flup well.
If you use a forked server, you will not be able to have a singleton at all (at least no singleton that lifes longer than your actual context).
With a threaded server, it should be possibe (but I am not so much in Django and Web servers!).
Have you tried such a code (as an additional module):
At the tree dots ("...") you have to add coding to create your singleton object, of course.
This is no productive code yet, but you can use it to check if singletons will work at all with your framework. For singletons are only possible with some kind of "global storage" at hand. Forked servers make this more difficult.
In the case, that "normal global storage" does not work, there is a different possibility available. You could store your singleton on the file system, using Pythons serialization facilites. But of course, this would be much more overhead in deed!