-
Notifications
You must be signed in to change notification settings - Fork 23
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
iterator getOpenFiles*(p: Pid): FileEntry
#382
Comments
iterator getOpenFiles*(p: Pid): Entry
iterator getOpenFiles*(p: Pid): FileEntry
The problems referenced can't be properly solved with something like
|
I disagree, an application can use
you have to do that anyways, but it typically means aborting in-flight connections, and it's worse than rate limiting when approaching limits or refusing new connections, as illustrated in nim-lang/Nim#18161 (comment). Less chances of broken transactions and data corruptions.
not sure how it relates to this RFC, you can use |
Great, but that isn't the problem in any of those referenced issues. It's a feature, and not a very practical one.
The result of these limitations would be an overly complex feature that provides little functionality and is tiresome to use. If my application is running out of file descriptors, I either need to stand up a new server, or fix a bug. That's it. This is speaking from experience as someone who has developed backend services for a living. More on-topic, the problem in those issues is that the async framework isn't handling reaching file descriptor limits correctly. It just raises an exception outside the running async routines, rather than redirecting it into them (or at least, that's the issue that
|
If all you can come up is a minimum of descriptors that's already very good, the average doesn't matter. And the minimum can easily be 1 if you don't know or you cannot know. |
Btw I downvoted because bugfixes should not imply new APIs. It helps if an API is only used internally, otherwise the surface area of the Nim stdlib gets bigger and bigger. Not sustainable. |
this is precisely why we have so, I re-iterate this RFC with |
Good but then you don't need an RFC at all. ;-) More importantly however, I don't know if the |
as @mrhdias mentioned in nim-lang/Nim#18205 (comment), python's psutil module has the ingredients for that, on all supported OSs (see https://psutil.readthedocs.io/en/latest/#psutil.Process.num_fds num_fds for unix-like platforms and num_handles for windows): import psutil
p = psutil.Process()
print(p.num_fds()) on linux, it uses the same approach as in this RFC, via: return len(os.listdir("%s/%s/fd" % (self._procfs_path, self.pid))) on other OS, IIUC avoids shelling out on OSX to psutil has a lot of generally useful APIs, and yes, we don't want to expose something to stdlib until it matures a bit, so std/private/psutils or std/private/osutils would be the place to start. |
As I stated here, that |
proposal
cross-platform
getOpenFiles
to retrieve the opened files for a given processexample use case
this can be used to implement a robust
activeDescriptors
andshouldAcceptRequest
, as follows:in fact this is what i implemented in timotheecour/Nim#750, for linux
osx
linux
list
/proc/self/fd
using C api calls to opendir, readdir, closedir (instead ofls -l /proc/<pid>/fd
), eg https://stackoverflow.com/questions/1121383/counting-the-number-of-files-in-a-directory-using-c?noredirect=1&lq=1windows
people more familiar with windows could expand on that
GetProcessHandleCount
lsof
The text was updated successfully, but these errors were encountered: