Skip to content

Commit

Permalink
[python] Fix multiprocessing pool on Python 3.8
Browse files Browse the repository at this point in the history
Processes are now spawned instead of forked, which can cause lockups and
lost processes
  • Loading branch information
salkinium committed Jan 29, 2023
1 parent 939208f commit 9b6beaa
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 51 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/compile-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all AVRs
run: |
(cd test/all && python3 run_all.py at --quick-remaining)
Expand All @@ -46,7 +46,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for SAMD0x, SAMD1x, SAMD2x
run: |
(cd test/all && python3 run_all.py samd0 samd1 samd2 --quick-remaining)
Expand All @@ -72,7 +72,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for SAMD5x, SAME5x, SAMG5x
run: |
(cd test/all && python3 run_all.py samd5 same5 samg5 --quick-remaining)
Expand All @@ -98,7 +98,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for SAME7x, SAMS7x, SAMV7x
run: |
(cd test/all && python3 run_all.py same7 sams7 samv7 --quick-remaining)
Expand All @@ -124,7 +124,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F0
run: |
(cd test/all && python3 run_all.py stm32f0 --quick-remaining)
Expand All @@ -150,7 +150,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F1
run: |
(cd test/all && python3 run_all.py stm32f1 --quick-remaining)
Expand All @@ -176,7 +176,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F2
run: |
(cd test/all && python3 run_all.py stm32f2 --quick-remaining)
Expand All @@ -202,7 +202,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F3
run: |
(cd test/all && python3 run_all.py stm32f3 --quick-remaining)
Expand All @@ -228,7 +228,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F4 Part 1
run: |
(cd test/all && python3 run_all.py stm32f4 --quick-remaining --split 3 --part 0)
Expand All @@ -254,7 +254,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F4 Part 2
run: |
(cd test/all && python3 run_all.py stm32f4 --quick-remaining --split 3 --part 1)
Expand All @@ -280,7 +280,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F4 Part 3
run: |
(cd test/all && python3 run_all.py stm32f4 --quick-remaining --split 3 --part 2)
Expand All @@ -306,7 +306,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F7 Part 1
run: |
(cd test/all && python3 run_all.py stm32f7 --quick-remaining --split 2 --part 0)
Expand All @@ -332,7 +332,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32F7 Part 2
run: |
(cd test/all && python3 run_all.py stm32f7 --quick-remaining --split 2 --part 1)
Expand All @@ -358,7 +358,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L0 Part 1
run: |
(cd test/all && python3 run_all.py stm32l0 --quick-remaining --split 2 --part 0)
Expand All @@ -384,7 +384,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L0 Part 2
run: |
(cd test/all && python3 run_all.py stm32l0 --quick-remaining --split 2 --part 1)
Expand All @@ -411,7 +411,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L1
run: |
(cd test/all && python3 run_all.py stm32l1 --quick-remaining)
Expand All @@ -437,7 +437,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L4 Part 1
run: |
(cd test/all && python3 run_all.py stm32l4 --quick-remaining --split 3 --part 0)
Expand All @@ -463,7 +463,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L4 Part 2
run: |
(cd test/all && python3 run_all.py stm32l4 --quick-remaining --split 3 --part 1)
Expand All @@ -489,7 +489,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L4 Part 3
run: |
(cd test/all && python3 run_all.py stm32l4 --quick-remaining --split 3 --part 2)
Expand All @@ -515,7 +515,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32L5
run: |
(cd test/all && python3 run_all.py stm32l5 --quick-remaining)
Expand All @@ -541,7 +541,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32G0
run: |
(cd test/all && python3 run_all.py stm32g0 --quick-remaining)
Expand All @@ -567,7 +567,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32G4 Part 1
run: |
(cd test/all && python3 run_all.py stm32g4 --quick-remaining --split 2 --part 0)
Expand All @@ -593,7 +593,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32G4 Part 2
run: |
(cd test/all && python3 run_all.py stm32g4 --quick-remaining --split 2 --part 1)
Expand All @@ -619,7 +619,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32H7 Part 1
run: |
(cd test/all && python3 run_all.py stm32h7 --quick-remaining --split 2 --part 0)
Expand All @@ -645,7 +645,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile HAL for all STM32H7 Part 2
run: |
(cd test/all && python3 run_all.py stm32h7 --quick-remaining --split 2 --part 1)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Mkdocs info
run: |
mkdocs --version
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Full run of docs.modm.io-generator-script
run: |
export TERM=xterm-256color
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Check environment
run: |
env
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Examples STM32F0 Series
if: always()
run: |
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Examples STM32F4 Only Discovery Board
if: always()
run: |
Expand All @@ -209,7 +209,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Install protobuf==3.20.1 grpcio-tools (pip)
run: |
pip3 install --upgrade --upgrade-strategy=eager protobuf==3.20.1 grpcio-tools
Expand All @@ -232,7 +232,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Check environment
run: |
which avr-g++
Expand Down Expand Up @@ -278,7 +278,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Quick compile HAL for Cortex-M Part 1
if: always()
run: |
Expand All @@ -303,7 +303,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Quick compile HAL for Cortex-M Part 2
if: always()
run: |
Expand All @@ -328,7 +328,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Quick compile HAL for Cortex-M Part 3
if: always()
run: |
Expand All @@ -353,7 +353,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Quick compile HAL for Cortex-M Part 4
if: always()
run: |
Expand All @@ -378,7 +378,7 @@ jobs:
git config --global --add safe.directory /__w/modm/modm
- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Install mkdocs mkdocs-material (pip)
run: |
pip3 install --upgrade --upgrade-strategy=eager mkdocs mkdocs-material
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Update lbuild
if: always()
run: |
pip3 install --upgrade --user --upgrade-strategy=eager modm
pip3 install --upgrade --user --upgrade-strategy=eager modm multiprocess
- name: Hosted Unittests
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_armcortexm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Compile STM32 Examples
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Update lbuild
run: |
pip3 install --upgrade --upgrade-strategy=eager modm
pip3 install --upgrade --upgrade-strategy=eager modm multiprocess
- name: Hosted Examples
shell: bash
Expand Down
7 changes: 4 additions & 3 deletions test/all/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import random
import tempfile
import argparse
import platform
import subprocess
import multiprocessing
import multiprocess
from pathlib import Path
from collections import defaultdict

Expand Down Expand Up @@ -94,7 +95,7 @@ def run_command(cmdline):
stderr=subprocess.PIPE, universal_newlines=True)
return (p.stdout, p.stderr, p.returncode)
except KeyboardInterrupt:
raise multiprocessing.ProcessError()
raise multiprocess.ProcessError()

def run_lbuild(command):
cmdline = ["lbuild"] + command
Expand Down Expand Up @@ -287,7 +288,7 @@ def build_device(run):

print("Using {} parallel jobs for {} devices".format(args.jobs, len(devices)))
try:
with multiprocessing.Pool(args.jobs) as pool:
with multiprocess.Pool(args.jobs) as pool:
test_runs = pool.map(build_device,
[TestRun(x, cache_dir, cache_limit) for x in devices])

Expand Down
Loading

0 comments on commit 9b6beaa

Please sign in to comment.