code: def wait_socket(_socket, session, timeout=1):
      
      directions = session.block_directions()
      if directions == 0:
          return 0
      readfds = [_socket] \
          if (directions & LIBSSH2_SESSION_BLOCK_INBOUND) else ()
      writefds = [_socket] \
          if (directions & LIBSSH2_SESSION_BLOCK_OUTBOUND) else ()
      return select(readfds, writefds, (), timeout)
docs: Helper function for testing non-blocking mode.
  
      This function blocks the calling thread for <timeout> seconds -
      to be used only for testing purposes.
  
      Also available at `ssh2.utils.wait_socket`