human
Complete this python program:
def get_postgres_connection(host, port, database=None):
assistant
#Here is the Python code you requested.

    """Returns a ``Deferred`` which fires with a pg8000 connection when one
    has been created.
    See http://pythonhosted.org//pg8000/dbapi.html#pg8000.connect for
    parameter information.
    :param host: Host to connect to.
    :param port: Port to connect to:
    :param database: Database to connect to.
    :return: ``Deferred`` that fires with a pg8000 connection.
    """
    def connect_to_postgres():
        try:
            return connect(host=host, user=u'postgres', port=port, database=database)
        except (InterfaceError, ProgrammingError) as e:
            Message.new(message_type=u'acceptance:integration:postgres_connect', exception=unicode(e.__class__), reason=unicode(e)).write()
            return False
    d = loop_until(reactor, connect_to_postgres)
    return d