Last active
October 22, 2019 06:58
-
-
Save sudocurse/a6f3b8f4fb1f55b1dfd2ec44fb80410a to your computer and use it in GitHub Desktop.
macos default fd ulimit is 256. why do i see 252?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
files = [] | |
while True: | |
try: | |
file = tempfile.TemporaryFile() | |
print("Created file:", file, file.name) | |
files.append(file) | |
except OSError: | |
print("Total: {}".format(len(files))) | |
break | |
for x in files: | |
x.close() | |
Author
sudocurse
commented
Oct 15, 2019
•
weeeirdddd
import resource
print("Max for process:", resource.RLIMIT_NOFILE) # maximum number of open file descriptors for the current process
print("Max for process:", resource.RLIMIT_OFILE) # The BSD name for RLIMIT_NOFILE.
('Max for process:', 8)
AttributeError: 'module' object has no attribute 'RLIMIT_OFILE'
oh but when i try it in python 3, it starts at 3:
10292 ◯ python3 fd.py
Created file: <_io.BufferedRandom name=3> 3
Created file: <_io.BufferedRandom name=4> 4
Created file: <_io.BufferedRandom name=5> 5
...
Created file: <_io.BufferedRandom name=254> 254
Created file: <_io.BufferedRandom name=255> 255
Total: 253
It gets one additional file in the count somehow
(this is 3.6) python 3 still gives me
Max for process: 8
Traceback (most recent call last):
File "fd.py", line 16, in <module>
AttributeError: module 'resource' has no attribute 'RLIMIT_OFILE'
lolololol real dingus hours right here, these look and act like enums. here's how i should be doing it:
print("Max for process:", resource.getrlimit(resource.RLIMIT_NOFILE))
print("Max for process:", resource.getrlimit(resource.RLIMIT_OFILE))
Max for process: (256, 9223372036854775807)
Traceback (most recent call last):
File "fd.py", line 16, in <module>
AttributeError: module 'resource' has no attribute 'RLIMIT_OFILE'
I wonder what 2^64-1. that tuple output is (soft, hard) limits.9223372036854775807
is
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment