views:

123

answers:

1

Is putting an object in a multi-processing queue independent from getting an object from it?

In other words, will putting an object block the process P1 if another process P2 is getting from it?

Update: I am assuming an infinite queue.

+1  A: 

My reading of the source code is that get obtains a read lock, which is independent of of the lock (called _notempty) acquired by put. If I understand correctly, concurrent gets can block each other, and concurrent puts can block each other (modulo your use of the block parameter), but that gets and puts do not mutually block.

Jonathan Feinberg
re: reading source: that's how I normally go but in this instance I felt lazy. I read the source code too anyways after reading your reply: the "write" side is decoupled from the "read" side through a a `Pipe`.
jldupont
Agh, I see that my comment was (understandably) taken the wrong way. I only meant that the multiprocessing stuff is "pure python", and available with all of the other standard modules. I didn't mean it like "RTFM N00B!". Anyway, I'm glad my answer was helpful. I hope it's correct. :)
Jonathan Feinberg