(self)
| 884 | self.dbapi_connection = None |
| 885 | |
| 886 | def __connect(self) -> None: |
| 887 | pool = self.__pool |
| 888 | |
| 889 | # ensure any existing connection is removed, so that if |
| 890 | # creator fails, this attribute stays None |
| 891 | self.dbapi_connection = None |
| 892 | try: |
| 893 | self.starttime = time.time() |
| 894 | self.dbapi_connection = connection = pool._invoke_creator(self) |
| 895 | pool.logger.debug("Created new connection %r", connection) |
| 896 | self.fresh = True |
| 897 | except BaseException as e: |
| 898 | with util.safe_reraise(): |
| 899 | pool.logger.debug("Error on connect(): %s", e) |
| 900 | else: |
| 901 | # in SQLAlchemy 1.4 the first_connect event is not used by |
| 902 | # the engine, so this will usually not be set |
| 903 | if pool.dispatch.first_connect: |
| 904 | pool.dispatch.first_connect.for_modify( |
| 905 | pool.dispatch |
| 906 | ).exec_once_unless_exception(self.dbapi_connection, self) |
| 907 | |
| 908 | # init of the dialect now takes place within the connect |
| 909 | # event, so ensure a mutex is used on the first run |
| 910 | pool.dispatch.connect.for_modify( |
| 911 | pool.dispatch |
| 912 | )._exec_w_sync_on_first_run(self.dbapi_connection, self) |
| 913 | |
| 914 | |
| 915 | def _finalize_fairy( |
no test coverage detected