From: Nikolaus R. <Nik...@ra...> - 2008-07-25 13:28:06
|
Hello, I was wondering if it would be possible to add thread-specific initialization and finalization functions to FUSE Python. They should be called whenever a thread is created and destroyed. One can already perform thread initialization by check if thread local variables have been set: class fs(fuse): def __init__(self): fuse.__init__(); self.local = thread.local() def initi_thread(self): self.local.somedata = something .... def getattr(self, path): if not hasattr(self.local.somedata): self.init_thread() but this is a bit clumsy since the last lines have to be added to every FUSE operation. Moreover, there is currently no way to execute code when a thread is finalized. In the C API one can define a destructor using pthreads_key_create, but this is not possible in Python. Csaba, what do you think about the idea? Best, -Nikolaus -- »It is not worth an intelligent man's time to be in the majority. By definition, there are already enough people to do that.« -J.H. Hardy PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |