(self, timeout=60)
| 506 | } |
| 507 | |
| 508 | def _test_connection(self, timeout=60): |
| 509 | self._connection_addr = None |
| 510 | |
| 511 | loop = asyncio.new_event_loop() |
| 512 | |
| 513 | try: |
| 514 | for i in range(timeout): |
| 515 | if self._connection_addr is None: |
| 516 | conn_spec = self._get_connection_spec() |
| 517 | if conn_spec is None: |
| 518 | time.sleep(1) |
| 519 | continue |
| 520 | |
| 521 | try: |
| 522 | con = loop.run_until_complete( |
| 523 | asyncpg.connect(database='postgres', |
| 524 | user='postgres', |
| 525 | timeout=5, loop=loop, |
| 526 | **self._connection_addr)) |
| 527 | except (OSError, asyncio.TimeoutError, |
| 528 | asyncpg.CannotConnectNowError, |
| 529 | asyncpg.PostgresConnectionError): |
| 530 | time.sleep(1) |
| 531 | continue |
| 532 | except asyncpg.PostgresError: |
| 533 | # Any other error other than ServerNotReadyError or |
| 534 | # ConnectionError is interpreted to indicate the server is |
| 535 | # up. |
| 536 | break |
| 537 | else: |
| 538 | loop.run_until_complete(con.close()) |
| 539 | break |
| 540 | finally: |
| 541 | loop.close() |
| 542 | |
| 543 | return 'running' |
| 544 | |
| 545 | def _run_pg_config(self, pg_config_path): |
| 546 | process = subprocess.run( |
no test coverage detected