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


Groups > de.comp.lang.python > #5432

asyncio Hintergrundprozess

X-Received by 2002:aed:2a4a:: with SMTP id k10mr15019325qtf.23.1550576695464; Tue, 19 Feb 2019 03:44:55 -0800 (PST)
X-Received by 2002:a0c:f705:: with SMTP id w5mr240612qvn.3.1550576695179; Tue, 19 Feb 2019 03:44:55 -0800 (PST)
Path csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!m21no1785436qta.0!news-out.google.com!f18ni4764qto.0!nntp.google.com!m21no1785434qta.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups de.comp.lang.python
Date Tue, 19 Feb 2019 03:44:54 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=79.221.173.245; posting-account=bJLXZgkAAABb3jyMkY8c6zg_6wF6pySF
NNTP-Posting-Host 79.221.173.245
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <53874eb1-02b1-4f41-adf5-8697dbf69457@googlegroups.com> (permalink)
Subject asyncio Hintergrundprozess
From Philipp Kraus <philipp.kraus.flashpixx@gmail.com>
Injection-Date Tue, 19 Feb 2019 11:44:55 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Lines 34
Xref csiph.com de.comp.lang.python:5432

Show key headers only | View raw


Hallo,

ich möchte in einem Pythonprogramm ein externes Programm ausführen. Ich kenne dazu popen, subprocess. Da ich aktuell mit Python 3.6 arbeite wäre mir eine Lösung mit asyncio lieber, damit arbeite ich aktuell aber das erste Mal und benötige dazu etwas Hilfe.

Das externe Programm ist ein Commandline Tool, was einmal gestartet und als Dämonprozess läuft, bis ich es mittels kill (unter Linux) beende. Ausgaben werden auf stdout bzw stderr geschrieben. Mein Python Programm soll genau das machen, d.h. das Programm starten (nicht blockierend) und wenn __del__ meiner Klasse aufgerufen wird, das Programm beenden. 
Die Ausgaben sollen in einen Logger (aktuell zum Test reicht stdout) geleitet werden.

Ich habe es mit

class MyProgram:

   def __init(self):
       self._pid = await asyncio.create_subprocess_exec('myprogram','-arg1 -arg2', stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)

   def __del__(self):
         self._pid.kill()

probiert aber ich scheitere daran die Ausgabe umzuleiten, um überhaupt zu sehen, ob das Programm startet.
Bin ich mit asyncio überhaupt richtig, oder wäre subsprocess evtl besser?

Danke für die Hilfe

Phil

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

asyncio Hintergrundprozess Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2019-02-19 03:44 -0800

csiph-web