PTFM-11932 Require synchronized access when reading self._queues.

This prevents a race condition where the producer has put an empty deque
into _queues and not gotten around to putting anything in it yet, and
the consumer sees the empty deque (which is in contravention of the
invariant we've documented). These manifested as "IndexError: deque
index out of range".

It should also prevent a (never before observed) race condition where
the producer sees that the queue it wants to write to already exists,
but before it gets around to appending to it, the consumer pops its last
item and removes it, so that the producer crashes when it actually tries
to do the append.