[Spread-users] Spread python poll() taking almost 100% CPU
Brian Moseley
bcm at maz.org
Fri Oct 1 17:23:47 EDT 2004
Tim Peters wrote:
> You'll be happy with that; or, if you don't want to do anything other
> than get msgs, just do a straight:
>
> msg = mbox.receive()
>
> and let it worry about figuring out when a msg is available.
i was having the same problem as the original poster, so i switched to
the poll/sleep technique. seems to work fine.
i'd prefer to not have to poll tho, for the reason you mentioned. using
poll, i have to continuously check that the connection is still
connected, and reconnect if it somehow dropped away underneath. yuck.
however, my listener is a daemon (using the java service wrapper at
http://wrapper.tanukisoftware.org/). i want to be able to run "mydaemon
stop" and have the os shut down my listener cleanly. but if i do that
and the shutdown hook disconnects the spread connection while the
listening thread is still in msg.receive(), i get an exception. yuck.
any idea how i can sit in msg.receive() and then have my shutdown hook
disconnect the spread connection gracefully?
More information about the Spread-users
mailing list