[Twisted-Python] PyHeartbeat cookbook recipe

My old PyHeartbeat recipe on the Cookbook site, included in the O'Reilly book too, has got a fresh new look, and a new Twisted implementation besides the old threaded one. Its shortness and double implementation may make it a nice first example for those trying to disentangle themselves from those pesky threads. ;-) PyHeartbeat - detecting inactive computers http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52302 -- Nicola Larosa - nico@tekNico.net "Laugh. But you too are going to sound like and old fart one day. And the respect you show or don't show for those that came before you is going to be what you instill in those that come after you." -- EvilTwinSkippy, Slashdot, June 2004

On Thu, 2004-09-16 at 15:11, Nicola Larosa wrote:
Its shortness and double implementation may make it a nice first example for those trying to disentangle themselves from those pesky threads. ;-)
Yes indeed, thanks for doing this. One comment though - it'd be better to use reactor.listenUDP and reactor.run() directly for simplicity's sake, the extra abstraction layers of services and application just make the example harder to understand. I don't want people to think Twisted is *too* abstract ;)

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I thought about that, and concluded that the recipe would come out longer and less structured that way, and that it would be best to directly show people the "right" way of setting up things. Maybe it's just that I'm now so accustomed to think in terms of app and services, that it's harder to go back to the old way.
I don't want people to think Twisted is *too* abstract ;)
But indeed it is, isn't it? Hiding the truth is tough, sometimes. ;-))) - -- Nicola Larosa - nico@tekNico.net "Laugh. But you too are going to sound like and old fart one day. And the respect you show or don't show for those that came before you is going to be what you instill in those that come after you." -- EvilTwinSkippy, Slashdot, June 2004 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBSoQDXv0hgDImBm4RAkJ/AKCEM3VHvwOWBvWB/h0jh2jZokDDYACfYTJI h83j1egtYFtq4ui7lk5aZ8E= =Gi1t -----END PGP SIGNATURE-----

On Sep 17, 2004, at 2:28 AM, Nicola Larosa wrote:
I agree -- I think it's not a good idea to make all the examples use reactor.run() and then when someone actually wants to write a program say "well gee now why the heck are you using *that*??" James

On Fri, 2004-09-17 at 02:28, Nicola Larosa wrote:
It'd come out slightly shorter, actually. As for the right way... using twistd is generally the right thing to do, yes, but if as in your previous example you want to show people how relatively low-level APIs work, reactor is probably better. The services abstraction isn't all that relevant to your example, since it's so simple. -- Itamar Shtull-Trauring http://itamarst.org

On Thu, 2004-09-16 at 15:11, Nicola Larosa wrote:
Its shortness and double implementation may make it a nice first example for those trying to disentangle themselves from those pesky threads. ;-)
Yes indeed, thanks for doing this. One comment though - it'd be better to use reactor.listenUDP and reactor.run() directly for simplicity's sake, the extra abstraction layers of services and application just make the example harder to understand. I don't want people to think Twisted is *too* abstract ;)

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I thought about that, and concluded that the recipe would come out longer and less structured that way, and that it would be best to directly show people the "right" way of setting up things. Maybe it's just that I'm now so accustomed to think in terms of app and services, that it's harder to go back to the old way.
I don't want people to think Twisted is *too* abstract ;)
But indeed it is, isn't it? Hiding the truth is tough, sometimes. ;-))) - -- Nicola Larosa - nico@tekNico.net "Laugh. But you too are going to sound like and old fart one day. And the respect you show or don't show for those that came before you is going to be what you instill in those that come after you." -- EvilTwinSkippy, Slashdot, June 2004 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBSoQDXv0hgDImBm4RAkJ/AKCEM3VHvwOWBvWB/h0jh2jZokDDYACfYTJI h83j1egtYFtq4ui7lk5aZ8E= =Gi1t -----END PGP SIGNATURE-----

On Sep 17, 2004, at 2:28 AM, Nicola Larosa wrote:
I agree -- I think it's not a good idea to make all the examples use reactor.run() and then when someone actually wants to write a program say "well gee now why the heck are you using *that*??" James

On Fri, 2004-09-17 at 02:28, Nicola Larosa wrote:
It'd come out slightly shorter, actually. As for the right way... using twistd is generally the right thing to do, yes, but if as in your previous example you want to show people how relatively low-level APIs work, reactor is probably better. The services abstraction isn't all that relevant to your example, since it's so simple. -- Itamar Shtull-Trauring http://itamarst.org
participants (3)
-
Itamar Shtull-Trauring
-
James Y Knight
-
Nicola Larosa