UbuntuServer 16.04 LTS system
After launch:
root @ webserv: / home / user # python3 script.py
# -*- coding: utf-8 -*- import multiprocessing as mp import sys import signal def main(): name = mp.current_process().name print(name+' Starting') if __name__ == '__main__': mp.freeze_support() mp.set_start_method('spawn') p_main = mp.Process(target=main) p_main.start() p_main.join() print('Скрипт завершает работу') print(p_main, p_main.is_alive()) #<Process(Process-1, stopped)> False print(mp.current_process().name) #MainProcess sys.exit() And the script goes into perpetual waiting mode.
Who faced? Like everything according to the instructions from the official. site. It can of course matter in Linux and Python, but I do not even know which way to look.
UPD: The script ends when you comment out p_main.join (). But this leads to a malfunction.
UPD: If I add to the end of the process (i.e. I kill it forcibly after the completion of logic)
os.killpg(mp.current_process().pid, signal.SIGTERM) then everything works out. Conclusion: the processes themselves are not completed.
mainfunction is somehow blocking code that runs indefinitely. Something like "while True". Actually, the above example works quite normally, since the function fulfills the entire code and leaves normally - Yaroslav SurzhikovProcess-1 Starting->Скрипт завершает работу-><Process(Process-1, stopped)> False->MainProcess- Yaroslav Surzhikovimport oswithimport sys- Yaroslav Surzhikovpython -mplatform->Linux-4.4.0-96-generic-x86_64-with-Ubuntu-16.04-xenial,python3 -V-> Python 3.5.2) - jfs