-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Conversation
The most significant improvement in the project for the last 6 years! |
There was a problem hiding this 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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
reddit2telegram/cron_app.py
Outdated
def _process_single_entry( | ||
submodule_name, | ||
config, | ||
is_test, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_test, | |
is_test=False, |
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.