'Construct a new Connection.
The constructor here is not public and is only called only by an
:class:`.Engine`. See :meth:`.Engine.connect` and
:meth:`.Engine.contextual_connect` methods.'

def __init__(self, engine, connection=None, close_with_result=False, _branch=False, _execution_options=None, _dispatch=None, _has_events=None):

    self.engine = engine
    self.dialect = engine.dialect
    self.__connection = (connection or engine.raw_connection())
    self.__transaction = None
    self.should_close_with_result = close_with_result
    self.__savepoint_seq = 0
    self.__branch = _branch
    self.__invalid = False
    self.__can_reconnect = True
    if _dispatch:
        self.dispatch = _dispatch
    elif (_has_events is None):
        self.dispatch = self.dispatch._join(engine.dispatch)
    self._has_events = (_has_events or ((_has_events is None) and engine._has_events))
    self._echo = self.engine._should_log_info()
    if _execution_options:
        self._execution_options = engine._execution_options.union(_execution_options)
    else:
        self._execution_options = engine._execution_options
    if (self._has_events or self.engine._has_events):
        self.dispatch.engine_connect(self, _branch)
