How non blocking read/write throught remote FileSystem

末鹿安然 提交于 2019-12-23 10:48:34

问题


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 blocking my reactor.


回答1:


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!-)




回答2:


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.



来源:https://stackoverflow.com/questions/1682515/how-non-blocking-read-write-throught-remote-filesystem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!