Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings
This repository was archived by the owner on Dec 2, 2021. It is now read-only.
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

How to kill multiprocess parent program? #16

Open
@daiguadaidai

Description

@daiguadaidai

I run program but can't kill parent proccess.

code:

#-*- coding:utf-8 -*-from concurrent import futuresimport osimport sysimport signal def test(num):    import time        print os.getpid()    time.sleep(100)    return time.ctime(), numdef handle_interrupt(signum, frame):    print 'CAUGHT SIGINT!!!!!!!!!!!!!!!!!!!'    sys.exit(1)def main():    signal.signal(signal.SIGTERM, handle_interrupt) # kill    signal.signal(signal.SIGINT, handle_interrupt)  # Ctrl+C    signal.signal(signal.SIGQUIT, handle_interrupt) # Ctrl+\    with futures.ProcessPoolExecutor(max_workers=3) as executor:        print 'id:', id(executor)        future1 = executor.submit(test,1)        future2 = executor.submit(test,2)        print future1        print future1        print future1.result()        print future2.result()if __name__ == '__main__':    main()

run and pressCtrl + C can exit program:

python mul_future.py id: 140637338392144<Future at 0x7fe8a35b8ad0 state=running><Future at 0x7fe8a35b8ad0 state=running>20822083^CCAUGHT SIGINT!!!!!!!!!!!!!!!!!!!CAUGHT SIGINT!!!!!!!!!!!!!!!!!!!CAUGHT SIGINT!!!!!!!!!!!!!!!!!!!CAUGHT SIGINT!!!!!!!!!!!!!!!!!!!

But use kill can't exit program

**session1:**run program:

python mul_future.py id: 140243206338128<Future at 0x7f8cdf41aad0 state=running><Future at 0x7f8cdf41aad0 state=running>20912092

**session2:**kill parent proccess:

ps -ef | grep pythonroot      2087  1910  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2091  2087  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2092  2087  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2093  2087  0 21:32 pts/0    00:00:00 python mul_future.pykill 2087ps -ef | grep pythonroot      2087  1910  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2091  2087  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2092  2087  0 21:32 pts/0    00:00:00 python mul_future.pyroot      2093  2087  0 21:32 pts/0    00:00:00 python mul_future.py

what should i do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp