Returns a cursor created from conn. This is intended to be used in a "with" block. The cursor will be closed upon exiting the block.
(conn)
| 570 | |
| 571 | @contextlib.contextmanager |
| 572 | def __auto_closed_cursor(conn): |
| 573 | """Returns a cursor created from conn. This is intended to be used in a "with" block. |
| 574 | The cursor will be closed upon exiting the block. |
| 575 | """ |
| 576 | cursor = conn.cursor() |
| 577 | cursor.conn = conn |
| 578 | try: |
| 579 | yield cursor |
| 580 | finally: |
| 581 | try: |
| 582 | cursor.close() |
| 583 | except Exception as e: |
| 584 | LOG.warn("Error closing Impala cursor: %s", e) |
| 585 | |
| 586 | |
| 587 | @pytest.fixture |
no test coverage detected