我的目标:启动N个子进程,每个进程处理不同的套接字集。
--这意味着需要不同的epoll对象。
问题:当我打电话时选择.epoll()在子进程中,它返回相同的对象。
下面是一个简单的例子:
from multiprocessing import Process,Lock
import time,select,os
class A(Process):
def run(self):
fd = select.epoll()
print 'A.pid=',os.getpid(),'poll_fd:', fd, fd.fileno()
while 1:
poll_list = fd.poll(timeout=3600)
for fd,events in poll_list:
pass
class B(Process):
def run(self):
fd = select.epoll()
print 'B.pid=',os.getpid(),'poll_fd:', fd, fd.fileno()
while 1:
poll_list = fd.poll(timeout=3600)
for fd,events in poll_list:
pass
A().start()
B().start()
为什么会这样?
我该怎么做才能修好它?
任何帮助都将不胜感激。?
因为这是不同的进程,所以epoll资源也不同。每个进程都有自己的一组文件号。为新资源选择最低可用文件号。这就是为什么两个进程使用相同的文件号。不需要修复。你知道吗
相关问题 更多 >
编程相关推荐