def poll(connection: connection, timeout: float=<NUM_LIT:1.0>) -> Iterable[Event]:
if timeout > <NUM_LIT:0.0>:<EOL><INDENT>log('<STR_LIT>'.format(timeout), logger_name=_LOGGER_NAME)<EOL><DEDENT>else:<EOL><INDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL><DEDENT>if select.select([connection], [], [], timeout) == ([], [], []):<EOL><INDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>log('<STR_LIT>', logger_name=_LOGGER_NAME)<EOL>connection.poll()<EOL>while connection.notifies:<EOL><INDENT>event = connection.notifies.pop(<NUM_LIT:0>)<EOL>log(str(event), logger_name=_LOGGER_NAME)<EOL>yield Event.fromjson(event.payload)<EOL><DEDENT><DEDENT>
Poll the connection for notification events.

    This method operates as an iterable. It will keep returning events until
    all events have been read.

    Parameters
    ----------
    connection: psycopg2.extensions.connection
        Active connection to a PostGreSQL database.
    timeout: float
        Number of seconds to block for an event before timing out.

    Returns
    -------
    event: Event or None
        If an event is available, an Event is returned.
        If no event is available, None is returned.

    Examples
    --------
    >>> events = [evt for evt in connection.poll()]

    >>> for evt in connection.poll():
            print(evt)