如何编译具有 >1024 个文件描述符的 python?

发布于 2024-12-03 16:04:34 字数 1425 浏览 3 评论 0原文

Supervisord 中问题的解决方法是: “编译一个支持 > 1024 个文件描述符的 Python”

https://github.com/Supervisor/supervisor /issues/26

有人可以指导我完成此任务需要进行哪些更改吗?我已经提取了 python 2.7.2 源代码并准备就绪。

运行 centos 5.6,如果这很重要的话。

谢谢。

更新:ulimit -n 已设置为 65535。这是我在启动supervisord 时遇到的完整错误:

回溯(最近一次调用最后一次): 文件“/usr/local/bin/supervisord”,第 8 行,位于 load_entry_point('supervisor==3.0a10', 'console_scripts', 'supervisord')() 文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py”,第 372 行,在 main 中 去(选项) 文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py”,第 382 行,在 go d.main()
文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py”,第 95 行,在 main 中 self.run()
文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py”,第 112 行,运行中 self.runforever()
文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py”,第 230 行,在 runforever 中 r, w, x = self.options.select(r, w, x, 超时)
文件“/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/options.py”,第 1113 行,选择 返回 select.select(r, w, x, 超时) ValueError:文件描述符超出 select() 范围

The workaround for an issue in supervisord is to:
"compile a Python that supports > 1024 file descriptors"

https://github.com/Supervisor/supervisor/issues/26

Can someone please walk me through what changes are necessary to accomplish this? I have the python 2.7.2 source extracted and ready to go.

Running centos 5.6, if that matters.

Thanks.

Update: ulimit -n is already set to 65535. This is the full error I'm getting when starting supervisord:

Traceback (most recent call last):
File "/usr/local/bin/supervisord", line 8, in
load_entry_point('supervisor==3.0a10', 'console_scripts', 'supervisord')()
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py", line 372, in main
go(options)
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py", line 382, in go d.main()
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py", line 95, in main
self.run()
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py", line 112, in run
self.runforever()
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/supervisord.py", line 230, in runforever
r, w, x = self.options.select(r, w, x, timeout)
File "/usr/local/lib/python2.7/site-packages/supervisor-3.0a10-py2.7.egg/supervisor/options.py", line 1113, in select
return select.select(r, w, x, timeout)
ValueError: filedescriptor out of range in select()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆蝶 2024-12-10 16:04:34

这实际上是底层 select(2) 系统调用的限制。

从手册页来看:

An fd_set is a fixed size buffer.  Executing FD_CLR() or FD_SET() with a value of fd 
that  is  negative  or  is equal  to  or  larger  than  FD_SETSIZE will result in 
undefined behavior. 

标准 FD_SETSIZE 是 1024。

/usr/include/linux/posix_types.h:#define __FD_SETSIZE   1024

所以这不是 Python 问题。 poll(2)epoll(2) 系统调用有更大的限制。您真正需要做的是使用 select.epoll 对象(仍在 select 模块中)而不是 `select。

That's actually the limit of the underlying select(2) system call.

From the man page:

An fd_set is a fixed size buffer.  Executing FD_CLR() or FD_SET() with a value of fd 
that  is  negative  or  is equal  to  or  larger  than  FD_SETSIZE will result in 
undefined behavior. 

And the standard FD_SETSIZE is 1024.

/usr/include/linux/posix_types.h:#define __FD_SETSIZE   1024

So it's not a Python issue. The poll(2) and epoll(2) system calls have a much larger limit. What you really need to do use use the select.epoll object (still in the select module) instead of `select.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文