Skip to content

Commit

Permalink
Use multiprocessing get_context and python 3.12 (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Mar 13, 2024
2 parents 4ddddf8 + 987e19f commit cc054eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
- linux: py39-oldestdeps-cov-xdist
- linux: py39-xdist
- linux: py310-xdist
- linux: py311-cov-xdist
- linux: py311-xdist
- linux: py312-cov-xdist
coverage: codecov
- macos: py311-xdist
test_downstream:
Expand Down
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
Changes to API
--------------

jump
~~~~

- Switch multiprocessing method to ``fork_server``. [#249]

ramp_fitting
~~~~~~~~~~~~

- Switch multiprocessing method to ``fork_server``. [#249]

Bug Fixes
---------

Expand Down
7 changes: 4 additions & 3 deletions src/stcal/jump/jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,10 @@ def detect_jumps(
),
)
log.info("Creating %d processes for jump detection ", n_slices)
pool = multiprocessing.Pool(processes=n_slices)
######### JUST FOR DEBUGGING #########################
# pool = multiprocessing.Pool(processes=1)
ctx = multiprocessing.get_context("forkserver")
pool = ctx.Pool(processes=n_slices)
######### JUST FOR DEBUGGING #########################
# pool = ctx.Pool(processes=1)
# Starts each slice in its own process. Starmap allows more than one
# parameter to be passed.
real_result = pool.starmap(twopt.find_crs, slices)
Expand Down
5 changes: 3 additions & 2 deletions src/stcal/ramp_fitting/ols_fit.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/env python

import logging
import multiprocessing
import time
import warnings
from multiprocessing import cpu_count
from multiprocessing.pool import Pool

import numpy as np

Expand Down Expand Up @@ -160,7 +160,8 @@ def ols_ramp_fit_multiprocessing(
ramp_data, buffsize, save_opt, readnoise_2d, gain_2d, weighting, number_slices
)

pool = Pool(processes=number_slices)
ctx = multiprocessing.get_context("forkserver")
pool = ctx.Pool(processes=number_slices)
pool_results = pool.starmap(ols_ramp_fit_single, slices)
pool.close()
pool.join()
Expand Down

0 comments on commit cc054eb

Please sign in to comment.