Skip to content

Commit

Permalink
backend: better handling of too many open files errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Jul 5, 2024
1 parent 5103c07 commit 6b0324f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/scheduler/unpacking_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def shutdown(self):
)
self.stop_containers()
self._clean_tmp_dirs()
self.manager.shutdown()
if self.manager:
self.manager.shutdown()
logging.info('Unpacking scheduler offline')

def _clean_tmp_dirs(self):
Expand Down Expand Up @@ -138,8 +139,9 @@ def create_containers(self):
self.worker_tmp_dirs.append(tmp_dir)

def stop_containers(self):
with ThreadPoolExecutor(max_workers=len(self.workers)) as pool:
pool.map(lambda container: container.stop(), self.workers)
if self.workers:
with ThreadPoolExecutor(max_workers=len(self.workers)) as pool:
pool.map(lambda container: container.stop(), self.workers)

def extraction_loop(self):
logging.debug(f'Starting unpacking scheduler loop (pid={os.getpid()})')
Expand Down
10 changes: 8 additions & 2 deletions src/start_fact_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,11 @@ def _check_ulimit():


if __name__ == '__main__':
FactBackend().main()
sys.exit(0)
backend = FactBackend()
try:
backend.main()
sys.exit(0)
except OSError as error:
logging.exception(f'Exception during start: {error}')
backend.shutdown()
sys.exit(1)

0 comments on commit 6b0324f

Please sign in to comment.