I am currently trying to implement same failsafe mechanism into my
FUSE Python filesystem.
My (at first sight straightforward) idea is to mark the filesystem as
needing an fsck whenever there is an unhandled exception in my code.
The problem is now how to detect such a condition.
My first solution was done write a custom function decorator that
simply catches all exceptions:
def wrapped(*a, **kw):
return fn(*a, **kw)
and apply it to all FUSE API methods:
def getattr(self, path):
def readdir(self, path):
However, this fails for readdir(), since readdir returns a generator.
If there are any problems in readdir, they only appear when the
generator is iterated. So this solution doesn't work.
My second approach was to define a global exception handler instead:
sys.excepthook = handle_exceptions
However, now the problem is that FUSE Python catches all IOError and
OSError exceptions in ErrnoWrapper without reraising them. So I am not
able to detect all errors.
I have thought about this for a while now, and the only solution that
I can come up with is to reraise the Exceptions in ErrnoWrapper.
Csaba, would such a change be possible? I can imagine that this will
make it more difficult to return the correct errno...
»It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C