Skip to content

Commit

Permalink
added multicore arg for experimental multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
c0m4r committed Feb 9, 2024
1 parent 6f920df commit fc99dc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/paranoya_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
help="Show a progress bar (experimental)",
default=False,
)
parser.add_argument(
"--multicore",
action="store_true",
help="Force paranoya to use all CPU cores (experimental)",
default=False,
)
parser.add_argument(
"--followlinks",
action="store_true",
Expand Down
23 changes: 20 additions & 3 deletions paranoya.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import sys
import threading
import traceback
from signal import signal, SIGPIPE, SIG_DFL, SIGTERM, SIGINT

from bisect import bisect_left
from collections import Counter
from multiprocessing import Process
from signal import signal, SIGPIPE, SIG_DFL, SIGTERM, SIGINT
from subprocess import Popen, PIPE, run
from types import FrameType
from typing import Optional
Expand Down Expand Up @@ -333,7 +333,19 @@ def scan_path(self, path):
new_directories.append(dirname)
directories[:] = new_directories

paranoya.scan_path_files(root, directories, files, progress_bar)
if args.multicore:
proc = Process(
target=paranoya.scan_path_files,
args=(
root,
directories,
files,
progress_bar,
),
)
proc.start()
else:
paranoya.scan_path_files(root, directories, files, progress_bar)

def perform_intense_check(
self,
Expand Down Expand Up @@ -1919,6 +1931,11 @@ def read_args() -> "argparse.Namespace":
"Skipping process memory check. User has no admin rights.",
)

if args.multicore:
args.progress = False
logger.log("NOTICE", "Init", "Multicore processing enabled (experimental)")
logger.log("NOTICE", "Init", "Progress will be unavailable")

# File scan mode
if args.d:
paranoya.run_daemon()
Expand Down

0 comments on commit fc99dc9

Please sign in to comment.