Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions billiard/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import subprocess
import sys
import warnings

from itertools import zip_longest

Expand Down Expand Up @@ -100,16 +101,35 @@
descriptor limit.

"""

try:
return os.sysconf('SC_OPEN_MAX')
fdmax = os.sysconf('SC_OPEN_MAX')
except:
pass
if resource is None: # Windows
return default
fdmax = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if fdmax == resource.RLIM_INFINITY:
return default
return fdmax
fdmax = None

if fdmax is None:
if resource is None: # Windows
return default
fdmax = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if fdmax == resource.RLIM_INFINITY:
return default
# Some system might be "mis"configured and allow for ulimit -n

Check failure on line 116 in billiard/compat.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

mis ==> miss, mist
# of e.g. 1073741816 which would be infeasible to sweep through.
if fdmax >= FD_MAX_LIMIT_THRESHOLD:
# limiting value is ad-hoc and already more than sensible
if default:
fdmax_limited = default
msg = "the default"
else:
fdmax_limited = FD_MAX_DEFAULT_LIMIT
msg = "a new smaller"
warnings.warn(
f"System set max number of open files ({fdmax}) is way too high. "
f"Will use {msg} value of {fdmax_limited}",
UserWarning)
return fdmax_limited
else:
return fdmax


def uniq(it):
Expand Down
Loading