Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82427
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cloverobert@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; 'sec': 0.16; 'subject:make': 0.16; 'subject:run': 0.16; 'all,': 0.19; 'command': 0.22; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'print': 0.22; 'file.': 0.24; 'script': 0.25; 'pass': 0.26; 'message-id:@mail.gmail.com': 0.30; 'pipe': 0.31; 'run': 0.32; 'skip:# 10': 0.33; 'received:google.com': 0.35; 'subject:?': 0.36; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'signal': 0.60; 'skip:o 30': 0.61 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=hJgG9ewiEnpuomzjGvoF0FgnifNeXgXPZ1MIQb+/p50=; b=kc0X5DzcbiFftrtFq+WLfebtPRCcwnPAnc5Vwz7WnQA8ljvmFC3T/bsIOSqdNSkguD +71ft9A9/JrJkUgqlL2HD34FoQJuTDu9hY/VXpH/x1CuRFDtgTQSurigZJA+lafCBf5A 9TLF46hbQ+khePS211IMpPDVu5+Booj3OzZKbqS0KKTUxWrq5FUEiDhra89rDY3scA7O JAsIYlhBD18QUOcPZW4xeYEYDlvSpDxXZkQ4U05ZYYjsDCPw4x3W67GB+IIjArD9uRya wfswo6nFMWirTVIXwUCFDMYxdExzHoXx0v9UQ0LfxzSwOidKshYHwIUt/gKpe8XOs56r 48LQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.202.48.82 with SMTP id w79mr8892487oiw.30.1418374089313; Fri, 12 Dec 2014 00:48:09 -0800 (PST) |
| Date | Fri, 12 Dec 2014 14:18:09 +0530 |
| Subject | How to make subprocess run for 60 sec? |
| From | Robert Clove <cloverobert@gmail.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=001a113cda36c09749050a00f3b9 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16900.1418374098.18130.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418374098 news.xs4all.nl 2887 [2001:888:2000:d::a6]:49908 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:82427 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi All,
I have the following python script that runs.
I want is to run the subprocess to run for 60 sec and then send the SIGINT
signal to subprocess and write the output in file.
#!/usr/bin/python
import os
import subprocess
PIPE = subprocess.PIPE
import signal
import time
def handler(signum, frame):
pass
signal.signal(signal.SIGALRM, handler)
signal.alarm(60)
command = "strace -c ./server"
os.chdir("/root/Desktop/")
p = subprocess.Popen(command, stdout=PIPE, stderr=PIPE)
time.sleep(60)
p.send_signal(signal.SIGINT)
signal.alarm(0)
print p.communicate()[1]
Regards
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
How to make subprocess run for 60 sec? Robert Clove <cloverobert@gmail.com> - 2014-12-12 14:18 +0530
csiph-web