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

Date 2013-12-24 16:41 +0100
From "Tobias M." <tm@tobix.eu>
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>
Newsgroups comp.lang.python
Message-ID <mailman.4593.1387899733.18130.python-list@python.org> (permalink)

Show all headers | 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