bpo-30966: Add multiprocessing.SimpleQueue.close() by vstinner · Pull Request #2776 · python/cpython

Or, rather, that would really only concern the close() method.

Sorry, but I'm a little bit lost. First, I understood that SimpleQueue is thread safe. Second, you say that in fact, locks are interprocess locks. Then I looked at Connection._send() and to me, it doesn't look thread safe:

    def _send(self, buf, write=_write):
        remaining = len(buf)
        while True:
            n = write(self._handle, buf)
            remaining -= n
            if remaining == 0:
                break
            buf = buf[n:]

_send() is not atomic: if write() is a partial write, thread A can send the begin of the buffer, and then thread B writes its data... I don't see how _send() could be atomic if the caller doesn't use a threading lock.

What are context locks? Interprocess locks? Threading locks? Both? :-)