Add lock for read/write to avoid interleaving receiving messages in mplex_stream.py