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


Groups > comp.lang.python > #62677

Re: Using asyncio in event-driven network library

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tm@tobix.eu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.122
X-Spam-Level *
X-Spam-Evidence '*H*': 0.76; '*S*': 0.00; 'yet.': 0.04; 'api.': 0.05; 'toolkit': 0.09; 'gui': 0.12; 'wrote': 0.14; 'fits': 0.16; 'iteration': 0.16; 'loop.': 0.16; 'received:188.40': 0.16; 'received:188.40.28': 0.16; 'received:your-server.de': 0.16; 'reedy': 0.16; 'subject:library': 0.16; 'wrote:': 0.18; 'library': 0.18; 'example': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'mind.': 0.24; 'pending': 0.26; 'this:': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'chris': 0.29; 'errors': 0.30; "i'm": 0.30; 'code': 0.31; 'about.': 0.31; 'concern': 0.31; 'idea,': 0.31; 'protocols': 0.31; 'this.': 0.32; 'stuff': 0.32; 'run': 0.32; 'core': 0.34; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'doubt': 0.36; 'interface,': 0.36; 'doing': 0.36; "didn't": 0.36; 'thanks': 0.36; 'should': 0.36; 'application': 0.37; 'easiest': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'itself': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'skip:u 10': 0.60; 'easy': 0.60; 'around.': 0.60; 'simple': 0.61; 'back': 0.62; 'kind': 0.63; 'myself': 0.63; 'skip:n 10': 0.64; 'became': 0.64; 'provide': 0.64; 'more': 0.64; 'note:': 0.66; 'approaches': 0.68; 'periodically': 0.68; 'christmas': 0.74; 'received:178': 0.74; 'hand': 0.80; 'adapted': 0.84; 'clearer': 0.84; 'holidays': 0.84; 'pump': 0.84; 'subject:Using': 0.84; 'avoided.': 0.91; 'reasoning': 0.91
Date Tue, 24 Dec 2013 16:41:53 +0100
From "Tobias M." <tm@tobix.eu>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8
MIME-Version 1.0
To python-list@python.org
Subject Re: Using asyncio in event-driven network library
References <52B82385.9080604@tobix.eu> <CAPTjJmrJO3eO8pPsDSmyA6QHBJfMa0CFs-aGm5zHRBrRTutcyQ@mail.gmail.com> <l9a4mm$484$1@ger.gmane.org>
In-Reply-To <l9a4mm$484$1@ger.gmane.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Authenticated-Sender tm@tobix.eu
X-Virus-Scanned Clear (ClamAV 0.97.8/18280/Tue Dec 24 12:52:26 2013)
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.4593.1387899733.18130.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387899733 news.xs4all.nl 2952 [2001:888:2000:d::a6]:33041
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62677

Show key headers only | View raw


Thanks for your answers! I didn't have the time to test any of your 
suggestions so far but they already gave me something to think about. At 
least now I'm much more clearer on what I am actually looking for.

On 23.12.2013 20:59, Terry Reedy wrote:
>
> What would be easiest for user-developers would be if someone were 
> able to wrap a gui loop in a way to give it the needed interface, so 
> the gui loop itself replaced and became the asyncio loop.
>
That's a good idea, maybe I will try this. On the other hand this means that
for every gui toolkit there must be a separate wrapper. I hoped this can 
be avoided.

On 23.12.2013 17:47, Chris Angelico wrote:
> You may be able to wrap your GUI code up so it fits inside asyncio.
> Rather than run a simple event loop, you could have your own loop that
> does some kind of checking: PyGTK has functions for peeking at events
> and doing just one iteration of the main loop, so you could pump all
> events with something like this:
>
> while gtk.events_pending(): gtk.main_iteration()
>
> No doubt other toolkits have something similar.
On 23.12.2013 20:59, Terry Reedy wrote:
> I think tk(inter) has 'run pending events' or something.
I didn't know functions like this exist in gui toolkits. Am I right in 
thinking that using these functions you don't have to use the built-in 
event loop. Instead you can write your own loop and just call 'run 
pending events' continuously?

I think what I actually want is the other way around. I want my library 
to be easy to use in existing gui applications that already have their 
own main loop. Their core should not need to be adapted for this. So I 
think I should provide a function like 'run pending events' in my api. 
For example in a PyQt application this could be called periodically by 
using a QTimer.

So I would use asyncio only if my library is used non-interactively with 
it's internal event loop.

Well, maybe I could reuse asyncio's transports and protocols in both 
situations. I don't know if they depend on asyncio's event loop.

Note: I didn't concern myself with all this stuff yet. Just wrote down 
what came to my mind. If there are any errors in my reasoning please 
correct me. I will try some approaches after the christmas holidays and 
get back to you then...

Thanks and regards,

Tobias

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


Thread

Re: Using asyncio in event-driven network library "Tobias M." <tm@tobix.eu> - 2013-12-24 16:41 +0100
  Re: Using asyncio in event-driven network library Christian Gollwitzer <auriocus@gmx.de> - 2013-12-25 14:52 +0100

csiph-web