Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plex: Add GENERATE_GUIDS, remove recursive thread calls #136

Merged
merged 7 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ MARK_FILE = "mark.log"
## Timeout for requests for jellyfin
REQUEST_TIMEOUT = 300

## Generate guids
## Generating guids is a slow process, so this is a way to speed up the process
## by using the location only, useful when using same files on multiple servers
GENERATE_GUIDS = "True"

## Generate locations
## Generating locations is a slow process, so this is a way to speed up the process
## by using the guid only, useful when using different files on multiple servers
GENERATE_LOCATIONS = "True"

## Max threads for processing
MAX_THREADS = 32

Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,19 @@ jobs:

- name: "Run tests"
run: |
# Move test/.env to root
mv test/ci.env .env
# Run script
# Test ci1
mv test/ci1.env .env
python main.py

# Test ci2
mv test/ci2.env .env
python main.py

# Test ci3
mv test/ci3.env .env
python main.py

# Test again to test if it can handle existing data
python main.py

cat mark.log
Expand Down
11 changes: 9 additions & 2 deletions src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,18 @@ def search_mapping(dictionary: dict, key_value: str):
return None


def future_thread_executor(args: list, threads: int = 32):
def future_thread_executor(
args: list, threads: int = None, override_threads: bool = False
):
futures_list = []
results = []

workers = min(int(os.getenv("MAX_THREADS", 32)), os.cpu_count() * 2, threads)
workers = min(int(os.getenv("MAX_THREADS", 32)), os.cpu_count() * 2)
if threads:
workers = min(threads, workers)

if override_threads:
workers = threads

# If only one worker, run in main thread to avoid overhead
if workers == 1:
Expand Down
Loading
Loading