Skip to content

Instantly share code, notes, and snippets.

@sudocurse
Last active October 22, 2019 06:58
Show Gist options
  • Save sudocurse/a6f3b8f4fb1f55b1dfd2ec44fb80410a to your computer and use it in GitHub Desktop.
Save sudocurse/a6f3b8f4fb1f55b1dfd2ec44fb80410a to your computer and use it in GitHub Desktop.
macos default fd ulimit is 256. why do i see 252?
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()
@sudocurse
Copy link
Author

sudocurse commented Oct 15, 2019

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 9223372036854775807 is 2^64-1. that tuple output is (soft, hard) limits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment