AttributeError:“模块”对象没有属性“轮询”

2024-06-26 13:26:42 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试使用gevent.select.poll监视/sys下的内容。下面的代码在使用本机Python时运行良好。当我使用gevent和do时

from gevent import monkey
monkey.patch_all()

from gevent import select  
p = select.poll()
p.register(fd, select.POLLERR | select.POLLPRI)

while True:
   if p.poll():
      <do something>
           

尝试使用select.select.poll()或尝试直接导入gevent。但是,它不断抛出“AttributeError:“module”对象没有属性“poll”。或者它一直扔:

 from gevent.select import poll
 ImportError: cannot import name poll

我有什么遗漏吗?从gevent代码中,我看到了poll类https://github.com/gevent/gevent/blob/master/src/gevent/select.py


Tags: 代码fromimportregister内容sysgeventall