Active Topics

 


Reply
Thread Tools
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#11
Originally Posted by v13 View Post
It depends on your program:

If you have a cpu-intensive program (let's say a password cracker - that runs all the time) that needs to communicate with the network you may need separate processes (but for the cpu-intensive part).

For most other cases you do this using select/poll or an API that is based on that (like asyncore or twisted).

On the other hand, if you're writing a GUI program you'll have to look at the toolkit's libraries for something that properly interacts with its main loop. Qt for example has a networking module that will fit your needs.
My app is not extremely CPU intensive.... I will think about what you've wrote, but looks like the select/poll thing is close to what I need. I would have to do it on sockets, since I want my app to be cross-platform.


Thanks,
L.

Last edited by luis; 2011-03-01 at 02:47.
 
Posts: 146 | Thanked: 15 times | Joined on Oct 2008
#12
Originally Posted by epage View Post
Take a look at the "login" and "_login" functions in the following file
https://github.com/epage/The-One-Rin...ice/session.py

"login" creates a AsyncLinearExecution which runs "_login" in the foreground thread but everything at a "yield" in a background thread. Looking at the "_login" function this takes what would be two or three callbacks with different kinds of state and simplifies it to a single function.

EDIT: And since I wrote that code, I've generalized it for both Qt and GTK. Makes callback code a lot simpler. Each piece of code after a "yield" is runs as a callback and you would have had to find a way to pass all that state to that callback.
Thanks a lot. I'll look at your code carefully.

Cheers!

L.
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:41.