[Stackless] Q2: Uthread's 'Thread' class
Just van Rossum
just at letterror.com
Fri Apr 13 09:22:31 CEST 2001
> Unfortunately, I still can't quite get it to add new thread objects into the
> mix from one which already exists.
> Stripped code follows; in it, the Client.run() never gets called, dispite
> the uthread.new(client.run) in the connection bit of the Server process. I
> think i'm just adding new threads the wrong way. :)
I snipped the code, as I didn't even have to try to run it to see that it
wouldn't work: you didn't instantiate a Client object, only a Server, and Server
doesn't have a run() method.
Anyway, thee might be another problem: you're using blocking sockets: uthreads
aren't OS threads, so if a socket blocks *all* uthreads will block, so I'm not
surprised this doesn't work. You should either use non-blocking sockets (eg.
combined with select) or use OS threads... This is not specific to sockets:
since uthreads are mostly implemented in Python, *any* call into C might block
I once tried to make a socket wrapper that would work with uthreads, which used
a separate uthread containing a select loop. It kindof worked, but I never
perfected it. If you like I can try to dig it out.
But: to learn about uthreads, try to do simple things first, without sockets and
other blocking calls...
Stackless mailing list
Stackless at starship.python.net
More information about the Stackless