Comments on: reactor.py http://laurentszyster.be/blog/reactor/ Python on Peers Sat, 04 Feb 2012 05:24:26 +0000 http://wordpress.org/?v=1.5.1.3 by: Laurent Szyster http://laurentszyster.be/blog/reactor/#comment-699 Mon, 22 May 2006 09:31:36 +0000 http://laurentszyster.be/blog/reactor/#comment-699 Hi Rene, >How are errors handled? With exceptions? There are no errors handled, and reactors don't raise exceptions. They just work, it's easy, they are simple. You may "break" a reactor by collecting something else than byte strings, but that's an improbable use case, a gross API error that should raise an exception. That exception in turn will be catched in the mainloop if not before. See async_loop.py for the implementation details (I know, I should beef that part of the doc). >Is there a way to own my main loop? Eg a dispatch_once() type call which gets called quite often. No. The short answer is that you need only one asynchronous loop. If you really need two, start two distinct processes that communicate together asynchronously. If you want to integrate that loop into a GUI thread, forget about it: you'll end-up on a road to GUIneverland where Twisted got lost. Think network, web user interfaces, AJAX. Network clients with GUI are a pain to develop, a nightmare to support and simply not portables. The network is the computer. The browser is the desktop. >Or can I run dispatch from a separate thread, and have it back that way? Threading is best applied inside the asynchronous loop, where needed to access synchronous and CPU intensive API that would otherwise block all that fine asynchronous design. >I just noticed your code is GPL. Not very compatible with lots of python uses. Well, this is free software like in free speech and free beer. Not free ride or freeloader ;-) Thanks for reading, Hi Rene,

>How are errors handled? With exceptions?

There are no errors handled, and reactors don’t raise exceptions. They just work, it’s easy, they are simple. You may “break” a reactor by collecting something else than byte strings, but that’s an improbable use case, a gross API error that should raise an exception.

That exception in turn will be catched in the mainloop if not before.

See async_loop.py for the implementation details (I know, I should beef that part of the doc).

>Is there a way to own my main loop? Eg a dispatch_once() type call which gets called quite often.

No.

The short answer is that you need only one asynchronous loop. If you really need two, start two distinct processes that communicate together asynchronously.

If you want to integrate that loop into a GUI thread, forget about it: you’ll end-up on a road to GUIneverland where Twisted got lost. Think network, web user interfaces, AJAX. Network clients with GUI are a pain to develop, a nightmare to support and simply not portables.

The network is the computer.

The browser is the desktop.

>Or can I run dispatch from a separate thread, and have it back that way?

Threading is best applied inside the asynchronous loop, where needed to access synchronous and CPU intensive API that would otherwise block all that fine asynchronous design.

>I just noticed your code is GPL. Not very compatible with lots of python uses.

Well, this is free software like in free speech and free beer.

Not free ride or freeloader ;-)

Thanks for reading,

]]>
by: Rene Dudfield http://laurentszyster.be/blog/reactor/#comment-692 Mon, 22 May 2006 07:41:27 +0000 http://laurentszyster.be/blog/reactor/#comment-692 How are errors handled? With exceptions? Is there a way to own my main loop? Eg a dispatch_once() type call which gets called quite often. Or can I run dispatch from a separate thread, and have it back that way? I just noticed your code is GPL. Not very compatible with lots of python uses. How are errors handled? With exceptions?

Is there a way to own my main loop? Eg a dispatch_once() type call which gets called quite often. Or can I run dispatch from a separate thread, and have it back that way?

I just noticed your code is GPL. Not very compatible with lots of python uses.

]]>
by: Laurent Szyster http://laurentszyster.be/blog/reactor/#comment-658 Sun, 21 May 2006 13:26:05 +0000 http://laurentszyster.be/blog/reactor/#comment-658 Hi Egg, I do not spend my time and energy on something new. Medusa was published in 1996. I'm not diverting the efforts of the Python community to provide an asynchronous framework for network peers. I'm just trying hard to improve the best one available. Regards, Hi Egg,

I do not spend my time and energy on something new. Medusa was published in 1996. I’m not diverting the efforts of the Python community to provide an asynchronous framework for network peers. I’m just trying hard to improve the best one available.

Regards,

]]>
by: Egg Shen http://laurentszyster.be/blog/reactor/#comment-640 Sun, 21 May 2006 05:48:10 +0000 http://laurentszyster.be/blog/reactor/#comment-640 At this point, I can no longer assume that anything you produce is based on any sort of sane/rational/healthy thought. You are so overly obsessed with the Twisted project that your opposition of it has become your identity, shadowing whatever usefulness the Allegra project may have. Your disparaging remarks give you less credibility, pointing a finger at you instead of your work. You've proven that you are very dedicated--imagine what you could do if instead of trying to one-up Twisted (which your comments show that you don't completely understand) you spent your time and energy on something new and different or lent a hand to an existing project without duplicating it's efforts. At this point, I can no longer assume that anything you produce is based on any sort of sane/rational/healthy thought. You are so overly obsessed with the Twisted project that your opposition of it has become your identity, shadowing whatever usefulness the Allegra project may have. Your disparaging remarks give you less credibility, pointing a finger at you instead of your work.

You’ve proven that you are very dedicated–imagine what you could do if instead of trying to one-up Twisted (which your comments show that you don’t completely understand) you spent your time and energy on something new and different or lent a hand to an existing project without duplicating it’s efforts.

]]>