Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

multiprocessing.Pool map hangs #122930

Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
@wdxal

Description

@wdxal
Issue body actions

Bug report

Bug description:

Q:
Run the following code, sometimes subprogres that is created by [class A's Pool or class B's Pool] is going to sleeping status, and there is not any error log output.
But code(#3 or #4)run success, code(#1 or #2) is not run,The reason is pool.close() and pool.join() is not writed in source code?

test.py

from multiprocessing import Pool
import os
from test_common import *

class Test:
    def __init__(self):
        self.A = A()
        self.B = B()

    def run(self):
        data_list = list(range(10001, 11984))

        a_list = self.A.run(data_list)
        print("self.A.run end") #1

        new_list = self.B.run(data_list, a_list)
        print("self.B.run end") #2


def main():
    run_module = Test()
    run_module.run()

if __name__ == '__main__':
    main()

---------------------------------------------
test_common.py

import os
import multiprocessing
from multiprocessing import Pool
import io
import datetime
import time

class A:
    def __init__(self):
        pass

    def run(self, data_list):
        a_list = []
        for item in data_list:
            file_path = "{}/{}.aaa".format("/tmp/aaa", item)
            a_list.append(file_path)

        pool_size = 1
        pool = Pool(pool_size)
        pool.map(methodA, a_list)
        print("A#run end") #3
        return a_list


def methodA(file_path):
    if os.path.isfile(file_path):
        return
    # other code

class B:
    def __init__(self):
        pass

    def run(self, data_list, a_list):        
        b_list = []
        for item in data_list:
            b_path = "{}/{}.bbb".format("/tmp/bbb", item)
            b_list.append(b_path)

        pool_size = 1
        pool = Pool(pool_size)
        pool.map(methodB, b_list)
 
        print("B#run end") #4
        return b_list

def methodB(b_path):
    if os.path.isfile(b_path):
        return
    # other code

CPython versions tested on:

3.10

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.