def return_socket(self, sock_info, publish_checkin=True):
        """Return the socket to the pool, or if it's closed discard it.

        :Parameters:
          - `sock_info`: The socket to check into the pool.
          - `publish_checkin`: If False, a ConnectionCheckedInEvent will not
            be published.
        """
        listeners = self.opts.event_listeners
        if self.enabled_for_cmap and publish_checkin:
            listeners.publish_connection_checked_in(self.address, sock_info.id)
        if self.pid != os.getpid():
            self.reset()
        else:
            if self.closed:
                sock_info.close_socket(ConnectionClosedReason.POOL_CLOSED)
            elif sock_info.pool_id != self.pool_id:
                sock_info.close_socket(ConnectionClosedReason.STALE)
            elif not sock_info.closed:
                sock_info.update_last_checkin_time()
                sock_info.update_is_writable(self.is_writable)
                with self.lock:
                    self.sockets.appendleft(sock_info)

        self._socket_semaphore.release()
        with self.lock:
            self.active_sockets -= 1
Return the socket to the pool, or if it's closed discard it.

        :Parameters:
          - `sock_info`: The socket to check into the pool.
          - `publish_checkin`: If False, a ConnectionCheckedInEvent will not
            be published.
        
stackoverflow/venv/lib/python3.6/site-packages/pymongo/pool.py