| 71 | self.proc = None |
| 72 | |
| 73 | def start(self): |
| 74 | if self.proc: |
| 75 | logging.info("proxy already started") |
| 76 | return |
| 77 | |
| 78 | logging.info("starting proxy") |
| 79 | pproxy_fix = str(Path(__file__).parent.parent / "tools/pproxy_fix.py") |
| 80 | cmdline = [sys.executable, pproxy_fix, "--reuse"] |
| 81 | cmdline += ["-l", f"tunnel://:{self.client_port}"] |
| 82 | cmdline += ["-r", f"tunnel://{self.server_host}:{self.server_port}"] |
| 83 | |
| 84 | self.proc = sp.Popen(cmdline, stdout=sp.DEVNULL) |
| 85 | logging.info("proxy started") |
| 86 | self._wait_listen() |
| 87 | |
| 88 | # verify that the proxy works |
| 89 | try: |
| 90 | with psycopg.connect(self.client_dsn): |
| 91 | pass |
| 92 | except Exception as e: |
| 93 | pytest.fail(f"failed to create a working proxy: {e}") |
| 94 | |
| 95 | def stop(self): |
| 96 | if not self.proc: |