diff options
author | Frederick Muriuki Muriithi | 2022-02-08 07:50:13 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-02-08 10:12:27 +0300 |
commit | 35092e0bf2c411c6a9cb2e7b5809fca604eec9e0 (patch) | |
tree | bae0c2911969b5b458366b1012a1d40136d4f9e6 /gn3 | |
parent | 97ae2273a12c89d6042611aa7885240370fae545 (diff) | |
download | genenetwork3-35092e0bf2c411c6a9cb2e7b5809fca604eec9e0.tar.gz |
Remove multiprocessing for stability
Web servers are long-running processes, and python is not very good at
cleaning up after itself especially in forked processes - this leads to memory
errors in the web-server after a while.
This commit removes the use of multiprocessing to avoid such failures.
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/computations/partial_correlations.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index f6804eb..9fcc54e 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -6,7 +6,6 @@ GeneNetwork1. """ import math -import multiprocessing as mp from functools import reduce, partial from typing import Any, Tuple, Union, Sequence @@ -15,12 +14,12 @@ import pandas import pingouin from scipy.stats import pearsonr, spearmanr +from gn3.settings import TEXTDIR from gn3.random import random_string from gn3.function_helpers import compose from gn3.data_helpers import parse_csv_line from gn3.db.traits import export_informative from gn3.db.datasets import retrieve_trait_dataset -from gn3.settings import TEXTDIR, MULTIPROCESSOR_PROCS from gn3.db.partial_correlations import traits_info, traits_data from gn3.db.species import species_name, translate_to_mouse_gene_id from gn3.db.correlations import ( @@ -339,14 +338,12 @@ def compute_partial( This implementation reworks the child function `compute_partial` which will then be used in the place of `determinPartialsByR`. """ - with mp.Pool(MULTIPROCESSOR_PROCS or (mp.cpu_count() - 1)) as pool: - return tuple( - result for result in - pool.starmap( - compute_trait_info, - ((primary_vals, control_vals, (tvals, tname), method) - for tvals, tname in zip(target_vals, target_names))) - if result is not None) + return tuple( + result for result in ( + compute_trait_info( + primary_vals, control_vals, (tvals, tname), method) + for tvals, tname in zip(target_vals, target_names)) + if result is not None) def partial_correlations_normal(# pylint: disable=R0913 primary_vals, control_vals, input_trait_gene_id, trait_database, |