MCPcopy Create free account
hub / github.com/apache/impala / __auto_closed_conn

Function __auto_closed_conn

tests/conftest.py:529–552  ·  view source on GitHub ↗

Returns a connection to Impala. This is intended to be used in a "with" block. The connection will be closed upon exiting the block. The returned connection will have a 'db_name' property. DEPRECATED: See the 'unique_database' fixture above to use Impala's custom python AP

(pytest_config, db_name=None, timeout=DEFAULT_CONN_TIMEOUT)

Source from the content-addressed store, hash-verified

527
528@contextlib.contextmanager
529def __auto_closed_conn(pytest_config, db_name=None, timeout=DEFAULT_CONN_TIMEOUT):
530 """Returns a connection to Impala. This is intended to be used in a "with" block.
531 The connection will be closed upon exiting the block.
532
533 The returned connection will have a 'db_name' property.
534
535 DEPRECATED:
536 See the 'unique_database' fixture above to use Impala's custom python
537 API instead of DB-API.
538 """
539 default_impalad = pytest_config.option.impalad.split(',')[0]
540 impalad_host = default_impalad.split(':')[0]
541 hs2_port = pytest_config.option.impalad_hs2_port
542
543 conn = impala_connect(host=impalad_host, port=hs2_port, database=db_name,
544 timeout=timeout)
545 try:
546 conn.db_name = db_name
547 yield conn
548 finally:
549 try:
550 conn.close()
551 except Exception as e:
552 LOG.warn("Error closing Impala connection: %s", e)
553
554
555@pytest.fixture

Callers 2

connFunction · 0.85
__unique_connFunction · 0.85

Calls 2

warnMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected