'Destroy queues that can no longer be used.
This way they can be replaced by new usable sockets.'

def destroy_queues(self, queues, proc):

    assert (not proc._is_alive())
    self._waiting_to_start.discard(proc)
    removed = 1
    try:
        self._queues.pop(queues)
    except KeyError:
        removed = 0
    try:
        self.on_inqueue_close(queues[0]._writer.fileno(), proc)
    except IOError:
        pass
    for queue in queues:
        if queue:
            for sock in (queue._reader, queue._writer):
                if (not sock.closed):
                    try:
                        sock.close()
                    except (IOError, OSError):
                        pass
    return removed
