-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-83923: Added os.getdtablesize function to os module
#124411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
os.getdtablesize function to os module
|
cc @skirpichev |
|
I think the failure of document builind isn't important, because it is a C extension. So there is no Python definition. |
|
No, it is. CI status should be green. You should document new functions in sphinx docs as well. |
Okay, I'm adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds interesting to expose getdtablesize() in Python.
|
It seems like the function is available on FreeBSD, macOS and Solaris, but not on OpenBSD nor NetBSD. |
You should check if the function is available by adding And then run |
|
Okay, Thanks for pointing out my mistake, and thanks for your review! |
|
@serhiy-storchaka @corona10 @erlend-aasland: Do you think that it's worth it to expose
|
|
In #83923
I think this‘s necessary, and intuitive. |
|
You can also use I do not think that we need to implement a third way. |
If you're familiar with POSIX but not with Python, this can be pretty tough for you. Like me, for example. |
|
|
Oh sorry, it should be |
|
Because of /*[clinic input]
os.getdtablesize
Return the maximum number of files a process can have open.
[clinic start generated code]*/
static PyObject *
os_getdtablesize_impl(PyObject *module)
{
int size;
#ifndef MS_WINDOWS
size = getdtablesize();
#endif /* !MS_WINDOWS */
return PyLong_FromLong(size);
}or #ifndef MS_WINDOWS
...
#else
static PyObject *
os_getdtablesize_impl(PyObject *Py_UNUSED(module)) { Py_RETURN_NONE; }
#endif /* !MS_WINDOWS */ |
|
@rruuaanng: I suggest you to pause the implementation until we decide if we should add the function or not. |
Okay, I think so. |
The glibc implements getdtablesize() by calling getrlimit(RLIMIT_NOFILE) on POSIX. Let's close the issue, I agree with @serhiy-storchaka that this function is redundant and it's not worth it to add it. Sorry @rruuaanng. I close the issue. |
os.getdtablesize(..)toos(posix) module #83923What's confusing me now is that it seems there's no equivalent to
getdtablesizeon Windows. If it's allowed, I could write an API to provide an estimated value for the Windows system.And I'm a bit confused about the
clinictag. This is my first time submitting changes to the C-API. Could you point out any mistakes I might have made? Thanks!!