From c4e0acae1f64a76a1c621b093885ce2135c4798f Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 8 Jun 2020 13:56:19 -0400 Subject: [PATCH] Work around a file descriptor issue in cheroot. There is an issue that was introduced in 8.1.0 that throws an error when file descriptor numbers are large (see https://github.com/cherrypy/cheroot/issues/249). We can't pin cheroot to an older version, as that breaks support for modern python versions. It isn't clear if limiting the size of our cache will really help -- the cheroot issue implies that it is leaking file descriptors, so this may not do anything useful. --- large_image/cache_util/cache.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/large_image/cache_util/cache.py b/large_image/cache_util/cache.py index 5b8d718df..217c43669 100644 --- a/large_image/cache_util/cache.py +++ b/large_image/cache_util/cache.py @@ -39,6 +39,10 @@ SoftNoFile, HardNoFile = resource.getrlimit(resource.RLIMIT_NOFILE) resource.setrlimit(resource.RLIMIT_NOFILE, (HardNoFile, HardNoFile)) SoftNoFile, HardNoFile = resource.getrlimit(resource.RLIMIT_NOFILE) + # When run under cheroot, cheroot can fail if the file descriptor is + # greater than 1024 (see github.com/cherrypy/cheroot/issues/249), so + # limit this further + SoftNoFile = min(SoftNoFile, 1024) # Reserve some file handles for general use, and expect that tile # sources could use many handles each. This is conservative, since # running out of file handles breaks the program in general.