This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pdb/ipdb is not usable on Linux (which works on Windows) from a single multiprocessing.Process when the main process is stuck at process.join()
Type: behavior Stage: resolved
Components: Interpreter Core, Library (Lib) Versions: Python 3.6, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: nartes
Priority: normal Keywords:

Created on 2017-11-30 17:55 by nartes, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
parallel_sandbox.py nartes, 2017-11-30 17:55
Messages (2)
msg307332 - (view) Author: nartes (nartes) * Date: 2017-11-30 17:55
https://asciinema.org/a/Sl7BTmS4krLdrLb9c4YeMgAG1
msg307343 - (view) Author: nartes (nartes) * Date: 2017-11-30 21:05
https://gist.github.com/efe828a7bbac97e02a7d83d2a2d78540

import io
import os
import sys
import multiprocessing


class B(multiprocessing.Process):
    @classmethod
    def _my_thread(self, a, b):
        print("Class method as a separate process entry point. (%s, %s)" % (a, b))

    def __init__(self, glock, *args, **kwargs):
        multiprocessing.Process.__init__(self, *args, **kwargs)

        self.glock = glock

    def run(self):
        try:
            sys.stdin = os.fdopen(0, 'r')
            sys.stdout = os.fdopen(1, 'w')

            self._run()
        except Exception as e:
            raise e
        finally:
            print("Sort of a process destructor, PID = %s" % os.getpid())
            for s in [sys.stdin, sys.stdout]:
                if s is not None and\
                   hasattr(s, 'close'):
                    s.close()

    def _run(self):
        print("Hello, World!")


class A:
    def __init__(self):
        self.glock = multiprocessing.Lock()

    def run(self):
        jobs = []
        for k in range(3):
            jobs.append(B(self.glock))
            #jobs.append(B(self.glock, None, None, None))
        jobs.append(multiprocessing.Process(
            target=B._my_thread,
            args=("one", "two")))

        for j in jobs:
            j.start()

        for j in jobs:
            j.join()


if __name__ == '__main__':
    A().run()
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76365
2017-11-30 21:05:40nartessetstatus: open -> closed
resolution: not a bug
messages: + msg307343

stage: resolved
2017-11-30 17:55:13nartescreate