469,571 Members | 1,591 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,571 developers. It's quick & easy.

Add/Remove Channels in Asyncore?

I've implemented a real basic IRC client class in 100 lines using
asynchat (yes I know about Twisted). The problem I'm having is
arbitrarily starting and stopping multiple instances of this class
after I call loop().

The asyncore docs seem to imply everything's fixed in stone once loop()
is called, where they say, "Once the initial channel(s) is(are)
created, calling the loop() function activates channel service, which
continues until the last channel (including any that have been added to
the map during asynchronous service) is closed."

After I call asyncore.loop(), I'd like to be able to add/remove clients
("channels"?) to/from execution by asyncore. Is this possible?

Thanks,
Chris

Dec 23 '06 #1
1 1668
Chris wrote:
I've implemented a real basic IRC client class in 100 lines using
asynchat (yes I know about Twisted). The problem I'm having is
arbitrarily starting and stopping multiple instances of this class
after I call loop().

The asyncore docs seem to imply everything's fixed in stone once loop()
is called, where they say, "Once the initial channel(s) is(are)
created, calling the loop() function activates channel service, which
continues until the last channel (including any that have been added to
the map during asynchronous service) is closed."

After I call asyncore.loop(), I'd like to be able to add/remove clients
("channels"?) to/from execution by asyncore. Is this possible?
the usual way to do that is to add new channels in callbacks, in
response to other server activities.

if you want to deal with this from the program calling asyncore.loop,
use the "count" option to tell loop to return after N events. e.g:

while 1:
asyncore.loop(0.05, count=20) # wait for max 1 second
add/remove channels here

</F>

Dec 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Michael Welsh | last post: by
5 posts views Thread by David M. Wilson | last post: by
2 posts views Thread by Freddie | last post: by
1 post views Thread by export | last post: by
reply views Thread by Tony Meyer | last post: by
5 posts views Thread by JamesHoward | last post: by
7 posts views Thread by billie | last post: by
reply views Thread by Giampaolo Rodola' | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.