views:

234

answers:

2

Hi, Is there a way to write and read files on a remote filesystem (such as NFS, SSHFS, or sambafs) in a way that read or write or even open return immediately with an error code ? In fact i'm using twisted and i want to know whether there is a safe way to access remote files without block my reactor ?

Regards Fab

+3  A: 

In Twisted, for remote filesystems just like for any other blocking calls, you can use threads.deferToThread -- a reasonably elegant way to deal with pesky blocking syscalls!-)

Alex Martelli
+1  A: 

This is actually very similar to my question asked here. It seems that the only way to get around the limitations of the operating system, at present, is to use threads or external processes to handle your file IO for you.

In a previous life (non-python or twisted, but very asynchronous), we ended up abstracting file IO out into a separate daemon that was essentially our 'file system worker'.

2.6.x versions of linux seem to have added more support for asychronous IO at the kernel level, with libaio being the support for it, but it looks pretty arcane and rather dubious in what it actually supports.

rhettg
Unfortunately AIO isn't in such good shape: http://stackoverflow.com/questions/87892/what-is-the-status-of-posix-asynchronous-i-o-aio (The first link in the question is of particular interest)
Jean-Paul Calderone