<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_socket(_socket, session, timeout=1):
 """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` """

    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)