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

Switch to ThreadPoolExecutor/ProcessPoolExecutor instead of using spawning processes #222

Merged
merged 5 commits into from
Nov 5, 2022

Conversation

lgyanf
Copy link
Contributor

@lgyanf lgyanf commented Nov 5, 2022

What does it do?

This is an attempt to fix the issue described in #221. cron_job.py spawns an uncontrollable number of Python processes, which leads to random OOM errors on servers with small amount of RAM.

This PR introduces a mechanism to control the amount of processes or switch to thread-based implementation to save even more memory.

@Fillll
Copy link
Owner

Fillll commented Nov 5, 2022

The most significant improvement in the project for the last 6 years!

Copy link
Owner

@Fillll Fillll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be fixed before merging?

random.shuffle(list_of_processes_to_start)
executor = _create_thread_pool(config)
executor.map(
lambda submodule_name: _process_single_entry(submodule_name, config),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should here be 3 args?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or argument by default as suggested above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Changed to the default argument.

def _process_single_entry(
submodule_name,
config,
is_test,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_test,
is_test=False,

@Fillll Fillll merged commit 960557b into Fillll:master Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants