I need to open a file which is NFS mounted to my server. Sometimes, the NFS mount fails in a manner that causes all file operations to deadlock. In order to prevent this, I need a way to let the open
function in python time out after a set period. E.g. something like open('/nfsdrive/foo', timeout=5)
. Of course, the default open
procedure has no timeout
or similar keyword.
Does anyone here know of a way to effectively stop trying to open a (local) file if the opening takes too long?
Note: I've already tried the urllib2 module, but it's timeout options only work for web requests, not local ones.