[Tutor] basic threading question

Alan Gauld alan.gauld at btinternet.com
Thu Jan 7 17:08:00 EST 2016


On 07/01/16 19:26, richard kappler wrote:

> several actually. Each new connection spawns a thread that reads and
> parses. 

First question. Do you need to read AND parse in the thread. Could you
not read the raw data and send that to a parsing thread? Usually reading
the data won't be a problem (especially if its all coming through the
same serial connection as you seem to suggest).

> Should the client close, I want the thread to terminate. 

Second: I've lost the thread (pardon the pun) on your architecture.
Which process is the client? Is that the thing sending the
messages to your code? Or is it the process spawning the threads?

> I've read says you don't kill threads, 

I'm no threading expert, and especially in Python. But I thought
there was some kind of "kill all threads" signal that could be
called?

> If the socket.recv returns 0 bytes, the docs tell me that means the client
> closed and therefore the server socket closes as well. 

Yes, but that's the secondary socket set up post the initial
connection. Are you connecting to the server(and thus are
the client?) or are you the server that the cameras(?) are
connecting to?

Hopefully others have been following this more closely, but I
need a wee reminder of the architecture. Which process is
serving what, and which is connecting, and sending what?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list