By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,922 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,922 IT Pros & Developers. It's quick & easy.

Add/Remove Channels in Asyncore?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.