Revert: CPU limits not working
This commit is contained in:
parent
7227297b45
commit
48e1f93891
@ -38,10 +38,6 @@ options:
|
||||
--keep-frames keep frames directory
|
||||
--max-memory MAX_MEMORY
|
||||
set max memory
|
||||
--max-cpu-cores MAX_CPU_CORES
|
||||
set max cpu cores
|
||||
--max-cpu-usage MAX_CPU_USAGE
|
||||
set cpu usage in percent
|
||||
```
|
||||
|
||||
Looking for a CLI mode? Using the -f/--face argument will make the program in cli mode.
|
||||
|
12
run.py
12
run.py
@ -34,8 +34,6 @@ parser.add_argument('--keep-fps', help='maintain original fps', dest='keep_fps',
|
||||
parser.add_argument('--gpu', help='use gpu', dest='gpu', action='store_true', default=False)
|
||||
parser.add_argument('--keep-frames', help='keep frames directory', dest='keep_frames', action='store_true', default=False)
|
||||
parser.add_argument('--max-memory', help='set max memory', default=16, type=int)
|
||||
parser.add_argument('--max-cpu-cores', help='set max cpu cores', default=multiprocessing.cpu_count(), type=int)
|
||||
parser.add_argument('--max-cpu-usage', help='set cpu usage in percent', default=100, type=int)
|
||||
|
||||
for name, value in vars(parser.parse_args()).items():
|
||||
args[name] = value
|
||||
@ -46,13 +44,9 @@ if os.name == "nt":
|
||||
|
||||
|
||||
def limit_resources():
|
||||
current_cpu_usage, current_cpu_cores = resource.getrlimit(resource.RLIMIT_CPU)
|
||||
if args['max_memory'] < 1:
|
||||
resource.setrlimit(resource.RLIMIT_DATA, (args['max_memory'] * 1024 * 1024 * 1024, -1))
|
||||
if args['max_cpu_usage'] < 1:
|
||||
resource.setrlimit(resource.RLIMIT_CPU, (args['max_cpu_usage'], current_cpu_cores))
|
||||
if args['max_cpu_cores'] < multiprocessing.cpu_count():
|
||||
resource.setrlimit(resource.RLIMIT_CPU, (current_cpu_usage, args['max_cpu_cores']))
|
||||
if args['max_memory'] <= 1:
|
||||
memory = args['max_memory'] * 1024 * 1024 * 1024
|
||||
resource.setrlimit(resource.RLIMIT_DATA, (memory, memory))
|
||||
|
||||
|
||||
def pre_check():
|
||||
|
Loading…
Reference in New Issue
Block a user