Title: How to kill multiprocess parent program? · Issue #16 · fluentpython/example-code · GitHub
Open Graph Title: How to kill multiprocess parent program? · Issue #16 · fluentpython/example-code
X Title: How to kill multiprocess parent program? · Issue #16 · fluentpython/example-code
Description: I run program but can't kill parent proccess. code: #-*- coding:utf-8 -*- from concurrent import futures import os import sys import signal def test(num): import time print os.getpid() time.sleep(100) return time.ctime(), num def handle_...
Open Graph Description: I run program but can't kill parent proccess. code: #-*- coding:utf-8 -*- from concurrent import futures import os import sys import signal def test(num): import time print os.getpid() time.sleep(1...
X Description: I run program but can't kill parent proccess. code: #-*- coding:utf-8 -*- from concurrent import futures import os import sys import signal def test(num): import time print os.getpid() time.sle...
Opengraph URL: https://github.com/fluentpython/example-code/issues/16
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to kill multiprocess parent program?","articleBody":"I run program but can't kill parent proccess.\r\n\r\ncode:\r\n\r\n```\r\n#-*- coding:utf-8 -*-\r\nfrom concurrent import futures\r\nimport os\r\nimport sys\r\nimport signal\r\n \r\ndef test(num):\r\n import time\r\n \r\n print os.getpid()\r\n time.sleep(100)\r\n return time.ctime(), num\r\n\r\ndef handle_interrupt(signum, frame):\r\n print 'CAUGHT SIGINT!!!!!!!!!!!!!!!!!!!'\r\n sys.exit(1)\r\n\r\ndef main():\r\n\r\n signal.signal(signal.SIGTERM, handle_interrupt) # kill\r\n signal.signal(signal.SIGINT, handle_interrupt) # Ctrl+C\r\n signal.signal(signal.SIGQUIT, handle_interrupt) # Ctrl+\\\r\n\r\n with futures.ProcessPoolExecutor(max_workers=3) as executor:\r\n print 'id:', id(executor)\r\n future1 = executor.submit(test,1)\r\n future2 = executor.submit(test,2)\r\n print future1\r\n print future1\r\n\r\n print future1.result()\r\n print future2.result()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n```\r\n\r\nrun and press `Ctrl + C` can exit program:\r\n\r\n```\r\npython mul_future.py \r\nid: 140637338392144\r\n\u003cFuture at 0x7fe8a35b8ad0 state=running\u003e\r\n\u003cFuture at 0x7fe8a35b8ad0 state=running\u003e\r\n2082\r\n2083\r\n^C\r\nCAUGHT SIGINT!!!!!!!!!!!!!!!!!!!\r\nCAUGHT SIGINT!!!!!!!!!!!!!!!!!!!\r\nCAUGHT SIGINT!!!!!!!!!!!!!!!!!!!\r\nCAUGHT SIGINT!!!!!!!!!!!!!!!!!!!\r\n```\r\n\r\n**But use kill can't exit program**\r\n\r\n**session1:**run program:\r\n\r\n```\r\npython mul_future.py \r\nid: 140243206338128\r\n\u003cFuture at 0x7f8cdf41aad0 state=running\u003e\r\n\u003cFuture at 0x7f8cdf41aad0 state=running\u003e\r\n2091\r\n2092\r\n```\r\n\r\n**session2:**kill parent proccess:\r\n\r\n```\r\nps -ef | grep python\r\nroot 2087 1910 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2091 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2092 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2093 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\n\r\nkill 2087\r\n\r\nps -ef | grep python\r\nroot 2087 1910 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2091 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2092 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\nroot 2093 2087 0 21:32 pts/0 00:00:00 python mul_future.py\r\n```\r\n\r\nwhat should i do?","author":{"url":"https://github.com/daiguadaidai","@type":"Person","name":"daiguadaidai"},"datePublished":"2017-11-15T14:23:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/16/example-code/issues/16"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:16631309-d869-efc3-9ed5-8d90efde296f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B64E:24328B:985B1B6:C934C10:696E056D |
| html-safe-nonce | bebccee7fce02288956aab6a12cd2e2d1ccb4bb0d9d9542c33c19a964b02e33e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjRFOjI0MzI4Qjo5ODVCMUI2OkM5MzRDMTA6Njk2RTA1NkQiLCJ2aXNpdG9yX2lkIjoiNjA4ODQ0NjI4OTM5NDkyNjk1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 85fe94caefe4b203879fd8e7869dd92ee14cf020b3e39ebfca6d50ee4df9ce0c |
| hovercard-subject-tag | issue:274173451 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fluentpython/example-code/16/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf988fa30e8163894f666763754352ebf2dd1b2db85bc0bfca0b601430ebc881/fluentpython/example-code/issues/16 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf988fa30e8163894f666763754352ebf2dd1b2db85bc0bfca0b601430ebc881/fluentpython/example-code/issues/16 |
| og:image:alt | I run program but can't kill parent proccess. code: #-*- coding:utf-8 -*- from concurrent import futures import os import sys import signal def test(num): import time print os.getpid() time.sleep(1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daiguadaidai |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b5131b207ddd175abf059a848d5f4302ec0606b02211b989013be49cf08593e |
| turbo-cache-control | no-preview |
| go-import | github.com/fluentpython/example-code git https://github.com/fluentpython/example-code.git |
| octolytics-dimension-user_id | 9216311 |
| octolytics-dimension-user_login | fluentpython |
| octolytics-dimension-repository_id | 25216588 |
| octolytics-dimension-repository_nwo | fluentpython/example-code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 25216588 |
| octolytics-dimension-repository_network_root_nwo | fluentpython/example-code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8590a63bfc8093b241930ca57d536c9a50f9680 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width