Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18412

Re: Avoid race condition with Popen.send_signal

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jerome@jolimont.fr>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.093
X-Spam-Evidence '*H*': 0.82; '*S*': 0.00; "(i'd": 0.09; '"normal"': 0.16; 'adam': 0.16; 'header:X-Face:1': 0.16; 'received:lan': 0.16; 'seconds,': 0.16; 'socket.': 0.16; 'subprocess,': 0.16; 'cc:addr :python-list': 0.16; 'say,': 0.19; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'trying': 0.21; 'mechanism': 0.21; 'header:In- Reply-To:1': 0.22; 'figure': 0.23; 'cc:2**0': 0.24; "i'm": 0.26; 'process,': 0.28; 'sound': 0.28; 'cc:addr:python.org': 0.29; 'url:library': 0.31; 'tue,': 0.32; 'something': 0.35; 'external': 0.35; 'url:python': 0.36; 'subject:with': 0.36; 'another': 0.37; 'using': 0.38; 'url:docs': 0.39; 'talk': 0.39; 'url:org': 0.39; 'should': 0.39; 'why': 0.39; 'more': 0.61; 'stop': 0.63; 'received:89': 0.64; '2012': 0.67; 'realized': 0.73; '-0800': 0.84; 'conservative': 0.84; 'either,': 0.84; 'place?': 0.84; 'plays': 0.91; 'to:none': 0.93
X-Spam-Checker-Version SpamAssassin 3.3.1 (2010-03-16) on jeftof
X-Spam-Level
X-Spam-Status No, score=0.2 required=7.0 tests=ALL_TRUSTED,MISSING_HEADERS autolearn=no version=3.3.1
Date Tue, 3 Jan 2012 16:09:36 +0100
From Jérôme <jerome@jolimont.fr>
Cc python-list@python.org
Subject Re: Avoid race condition with Popen.send_signal
In-Reply-To <8614ceb1-f31f-4904-b2b9-6ef0d2bc7cdc@m20g2000vbf.googlegroups.com>
References <CABicbJKPmckzRwKa9BgTzP8p+nVO98eKh2s1=ZDjBSoY-N1OvQ@mail.gmail.com> <mailman.4327.1325555666.27778.python-list@python.org> <63817f2b-ccf8-4d7d-92a6-c1d622986d8a@j10g2000vbe.googlegroups.com> <mailman.4339.1325580095.27778.python-list@python.org> <8614ceb1-f31f-4904-b2b9-6ef0d2bc7cdc@m20g2000vbf.googlegroups.com>
X-Mailer Claws Mail 3.7.10 (GTK+ 2.24.8; x86_64-pc-linux-gnu)
X-Face "kBB1-!wF@,"j_&tJ&7; T,t)PeQkZg5?.:{p,s>/,+?b6pN5!yxZy^nRXA=*?W+|J9OG!W[rdx^VA^Sx`R"g,; +MzhAq"tZFg27W4qX+ZXvLX=%piZ6c.7@oSDHyQ0Mff#HGx<{
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4355.1325603216.27778.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325603216 news.xs4all.nl 6928 [2001:888:2000:d::a6]:33679
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18412

Show key headers only | View raw


Tue, 3 Jan 2012 06:12:59 -0800 (PST)
Adam Skutt a écrit:

> The conservative approach is to use another IPC mechanism to talk to
> the process, such as a pipe or a socket.  Why are you trying to send
> the child process SIGINT in the first place?

Say, you've got an application that plays a sound for a few seconds, using an
external program for that (beep, sox). If you close the application, you want
the sound to stop as well.

I don't know much about subprocess, not much more than what is in the
tutorial : http://docs.python.org/library/subprocess.html

(I don't know much about signalling either, I'm learning...)

I naively thought kill() was the "normal" way. Then realized terminate() or
even send_signal(SIGINT) would be softer.

What would be a good approach, then ?

Should I try something like this ?

	communicate(input="Ctrl+C")

(I'd need to figure out how to write Ctrl+C...)

Would that be cross-platform ?

-- 
Jérôme

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Avoid race condition with Popen.send_signal Cameron Simpson <cs@zip.com.au> - 2012-01-03 12:44 +1100
  Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-02 19:16 -0800
    Re: Avoid race condition with Popen.send_signal Cameron Simpson <cs@zip.com.au> - 2012-01-03 15:53 +1100
      Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-03 06:52 -0800
    Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 09:44 +0100
      Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-03 06:12 -0800
        Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 16:09 +0100
          Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-03 09:58 -0800
            Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 19:45 +0100
    Re: Avoid race condition with Popen.send_signal Chris Angelico <rosuav@gmail.com> - 2012-01-03 19:58 +1100
      Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-03 06:20 -0800
    Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 10:38 +0100
      Re: Avoid race condition with Popen.send_signal Adam Skutt <askutt@gmail.com> - 2012-01-03 07:03 -0800
        Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 17:24 +0100
        Re: Avoid race condition with Popen.send_signal Jérôme <jerome@jolimont.fr> - 2012-01-03 18:25 +0100

csiph-web