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


Groups > comp.lang.python > #3751

Re: Why doesn't this asyncore.dispatcher.handle_read() get called?

From Dun Peal <dunpealer@gmail.com>
Newsgroups comp.lang.python
Subject Re: Why doesn't this asyncore.dispatcher.handle_read() get called?
Date 2011-04-20 14:17 -0700
Organization http://groups.google.com
Message-ID <debb8ec8-5f95-4b7a-9fe5-777b72cfa981@i39g2000prd.googlegroups.com> (permalink)
References <11c683ce-3687-4a07-9d59-0371ba84562e@e8g2000vbz.googlegroups.com> <1ef2274c-7b8a-4e93-bbbc-d791df0e93da@j35g2000prb.googlegroups.com>

Show all headers | View raw


On Apr 20, 3:01 pm, Jean-Paul Calderone <calderone.jeanp...@gmail.com>
wrote:
> You didn't let the program run long enough for the later events to
> happen.  loop(count=1) basically means one I/O event will be processed
> - in the case of your example, that's an accept().  Then asyncore is
> done and it never gets to your custom handle_read.

Wow, a response from a Twisted founder and core developer =)

You were right, of course. Incrementing the count to 2 on the
asyncore.loop() calls makes the snippet work as expected.

I'd definitely rather use Twisted. It's unclear why transmitting a
bytestream message between two servers should require low-level socket
incantations such as `self.create_socket(socket.AF_INET,
socket.SOCK_STREAM)` or `self.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)`. The stdlib should offer a higher-level
asynchronous communication abstraction to support such a
straightforward usecase. Twisted does provide that, but my humble
needs can't justify the extra dependency cost.

Thanks a lot, D.

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


Thread

Why doesn't this asyncore.dispatcher.handle_read() get called? Dun Peal <dunpealer@gmail.com> - 2011-04-20 09:25 -0700
  Re: Why doesn't this asyncore.dispatcher.handle_read() get called? Jean-Paul Calderone <calderone.jeanpaul@gmail.com> - 2011-04-20 13:01 -0700
    Re: Why doesn't this asyncore.dispatcher.handle_read() get called? Dun Peal <dunpealer@gmail.com> - 2011-04-20 14:17 -0700

csiph-web