def test_connect_checkout_handler_always_gets_info(self):
        """test [ticket:3497]"""

        dbapi, p = self._queuepool_dbapi_fixture(
            pool_size=2, max_overflow=2)

        c1 = p.connect()
        c2 = p.connect()

        c1.close()
        c2.close()

        dbapi.shutdown(True)

        bad = p.connect()
        p._invalidate(bad)
        bad.close()
        assert p._invalidate_time

        @event.listens_for(p, "connect")
        def connect(conn, conn_rec):
            conn_rec.info['x'] = True

        @event.listens_for(p, "checkout")
        def checkout(conn, conn_rec, conn_f):
            assert 'x' in conn_rec.info

        assert_raises(
            Exception,
            p.connect
        )

        p._pool.queue = collections.deque(
            [
                c for c in p._pool.queue
                if c.connection is not None
            ]
        )

        dbapi.shutdown(False)
        c = p.connect()
        c.close()
dataset/ETHPy150Open zzzeek/sqlalchemy/test/engine/test_pool.py/QueuePoolTest.test_connect_checkout_handler_always_gets_info/original