Threads vs subprocesses

J

John O'Hagan

I have a program in which the main thread launches a number of CPU-intensive
worker threads. For each worker thread two python subprocesses are started,
each of which runs in its own terminal: one displays output received from the
worker thread via a socket, the other takes text input to control the thread
(this is done by having another thread receive the input via a socket and write
to the worker thread's arguments).

So far so good, but it occurred to me that instead of launching all these
worker threads, I could just put their target code in separate executable
files and launch them as subprocesses. That way there would be fewer threads,
but each subprocess would be doing more work.

My question is, on a single core machine, what are the pros and cons of
threads vs subprocesses in a setup like this?

Thanks,

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top