我注意到gevent支持类文件对象的包装器:http://www.gevent.org/gevent.fileobject.html
gevent.monkey.patch_all
方便地对socket
和time
等模块进行补丁,使其对gevent
友好。阅读代码,patch_all()
似乎没有调用显式的patch_file()
,但它确实调用了patch_builtins()
。这个函数的实现有点神奇。我不清楚这是否会修补内置的file
对象。
有人知道吗?
不,内置的file
没有打补丁。您需要使用gevent
FileObject