threading

Roy Smith roy at panix.com
Tue Apr 8 09:19:05 EDT 2014


In article <mailman.9008.1396954078.18130.python-list at python.org>,
 Sturla Molden <sturla.molden at gmail.com> wrote:
 
> The problem here is the belief that "thread-safety cannot be abstracted
> out". It can. The solution is to share nothing and send messages through
> queues.

Thread 1 and Thread 2 use a pair of queues to communicate.  T1 sends 
work to T2 using Q1, and T2 sends back results using Q2.

T1 pushes Item1 onto Q1, and waits for Result1 to come back on Q2.

T2 reads Item1 from its end of Q1, and waits to read Item2, which it 
needs to compute Result1.

Sounds like a deadlock to me.



More information about the Python-list mailing list