muhuk asks Dec 16, 2008 05:53PM don't you (KDE users) feel all vulnerable and exposed without a good trash management system?
shaf Dec 16, 2008 06:01PM nice to see ppl giving back to the community.. ps __trash_singleton ?? (!!)
muhuk says Dec 16, 2008 06:18PM shaf: that's very very old code. It was one of my first projects for learning python.
muhuk says Dec 16, 2008 06:18PM But it still works on my box New version is cooking, soon to be committed.
muhuk says Dec 16, 2008 07:38PM shaf: stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python
timka.org says Dec 16, 2008 09:54PM shaf: I use __new__ which always returns the single instance stored in a class attribute
shaf Dec 16, 2008 09:58PM yeah but what's to stop you from executing the script using another python intepreter ? Singleton breaks.
shaf Dec 16, 2008 09:59PM It's just that singleton is the simplest pattern to understand but can be tricky to implement if you don't understand your compiler/interptr
timka.org says Dec 16, 2008 10:12PM shaf: Another interpreter runs another instance of your program which has its own singleton instance.
timka.org says Dec 16, 2008 10:55PM shaf: I mean Singleton is usually limited to one process no matter what language you use, so multiple *program* instances is out of scope.
shaf Dec 16, 2008 10:58PM timka_org yep. I know all this already. But as any good programmer would know, singleton in practice is not guarenteed
shaf Dec 16, 2008 11:01PM especially read the last few paragraphs of this ... en.wikipedia.org/wiki/Singleton_pattern#Implementation
timka.org says Dec 16, 2008 11:07PM Yeah, in our production environment at work two instances of our app can fuck up the DB just because nobody cared about proper locking
timka.org says Dec 16, 2008 11:10PM It's about thread-safety inside single process, but you were talking about multiple processes
shaf Dec 16, 2008 11:11PM hence the reason for me to have mixed feelings about it. If used - use it carefully
muhuk says Dec 17, 2008 07:22AM on the other hand, most of the time singleton is not really needed in practice. Surely there is one trash (per user) but I have come to...
muhuk says Dec 17, 2008 07:23AM ...realize I don't need a singleton trash wrapper class at all. It is even making things harder to unittest.
muhuk says Dec 17, 2008 07:24AM Btw, a singleton shouldn't be confused as a concurrency mechanism (especially in multi-process systems).
timka.org says Dec 17, 2008 07:34AM Anyway, Singleton is just an object creation pattern, conceptually it has nothing to do with concurrency.
timka.org says Dec 17, 2008 07:37AM However, correct implementations must be aware of the used concurrency model