code: def _setup_resources():
      
      target_procs = 10240
      cur_proc, max_proc = resource.getrlimit(resource.RLIMIT_NPROC)
      target_proc = min(max_proc, target_procs) if max_proc > 0 else target_procs
      resource.setrlimit(resource.RLIMIT_NPROC, (max(cur_proc, target_proc), max_proc))
      cur_hdls, max_hdls = resource.getrlimit(resource.RLIMIT_NOFILE)
      target_hdls = min(max_hdls, target_procs) if max_hdls > 0 else target_procs
      resource.setrlimit(resource.RLIMIT_NOFILE, (max(cur_hdls, target_hdls), max_hdls))
docs: Attempt to increase resource limits up to hard limits.
  
      This allows us to avoid out of file handle limits where we can
      move beyond the soft limit up to the hard limit.