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


Groups > comp.lang.python > #73262

Question about asyncio

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'handler': 0.05; 'subject:Question': 0.07; 'caller': 0.09; 'cherrypy,': 0.09; 'http': 0.09; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'modified.': 0.16; 'modify,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'responses.': 0.16; 'suspend': 0.16; 'bit': 0.19; 'app': 0.19; 'trying': 0.19; 'replacing': 0.19; 'sends': 0.24; 'right.': 0.26; 'required.': 0.27; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'quite': 0.32; 'basic': 0.35; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'executing': 0.36; 'doing': 0.36; 'thanks': 0.36; 'changing': 0.37; 'application': 0.37; 'too': 0.37; 'connections': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'entire': 0.61; 'simple': 0.61; 'myself': 0.63; 'telling': 0.64; 'frank': 0.68; 'dozens': 0.84; 'listens': 0.84; 'working,': 0.84; 'approach.': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From "Frank Millman" <frank@chagford.com>
Subject Question about asyncio
Date Fri, 13 Jun 2014 13:42:00 +0200
X-Gmane-NNTP-Posting-Host 197.87.50.14
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.3790.4657
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.3790.4913
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.11055.1402659734.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1402659734 news.xs4all.nl 2976 [2001:888:2000:d::a6]:38434
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73262

Show key headers only | View raw


Hi all

I am trying to get to grips with asyncio, but I don't know if I am doing it 
right.

I have an app that listens for http connections and sends responses. I had 
it working
with cherrypy, which uses threading. Now I am trying to convert it to 
asyncio,
using a package called aiohttp.

I got a basic version working quite quickly, just replacing cherrpy's
request handler with aiohttp's, with a bit of tweaking where required.

Now I want to use the functionality of asyncio by using a 'yield from' to
suspend the currently executing function at a particular point while it
waits for some information. I find that adding 'yield from' turns the
function into a generator, which means that the caller has to iterate over
it. I can avoid that by telling the caller to 'yield from' the generator,
but then *its* caller has to be modified. Now I find I am going through my
entire application and changing every function into a coroutine by
decorating it with @asyncio.coroutine, and changing a simple function call
to a 'yield from'.

So far it is working, but there are dozens of functions to modify, so before
digging too deep a hole for myself I would like to know if this feels like
the right approach.

Thanks

Frank Millman


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


Thread

Question about asyncio "Frank Millman" <frank@chagford.com> - 2014-06-13 13:42 +0200

csiph-web