Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separately': 0.09; 'module?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'twisted': 0.16; 'all,': 0.19; 'trying': 0.19; 'input': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; "i'm": 0.30; 'protocols': 0.31; 'writes:': 0.31; 'run': 0.32; 'packaging': 0.33; 'connection': 0.35; 'but': 0.35; 'should': 0.36; 'two': 0.37; 'message- id:@gmail.com': 0.38; 'server': 0.38; 'to:addr:python-list': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'chain': 0.60; 'back': 0.62; 'kind': 0.63; 'url:a': 0.72; 'acts': 0.74; 'revive': 0.84; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Akira Li <4kir4.1i@gmail.com> Subject: Re: asyncio: wrapping a subprocess in a server Date: Thu, 26 Jun 2014 00:40:06 +0400 References: Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: 89.169.229.68 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:jWBO5igEo/RjGtNfzEKnnXQKWIU= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403728819 news.xs4all.nl 2918 [2001:888:2000:d::a6]:50912 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73588 David Farler writes: > Hi all, > > I'm trying to vend some kind of server that spawns a client-unique > subprocess when a client connects. The server acts as a middleman, > receiving structure messages from the client, sending input to the > subprocess, and packaging up subprocess data before sending back to > the client. The connection is long-lived and the client can continue > to send "requests". If the subprocess crashes or dies, the server > should be able to revive it transparently. > > I know how to separately create server and subprocess protocols and > having the event loop run either until completion, but what is the > best way to chain two protocols together? > > || Client || <~~ TCP ~~> || Server <--> Subprocess || Here's an example that uses Twisted http://stackoverflow.com/a/11729467 javascript client <--> websocket <--> twisted server <--> subprocess Do you want the same but using asyncio module? -- Akira