File: pproxy_fix.py

package info (click to toggle)
psycopg3 3.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,836 kB
  • sloc: python: 46,657; sh: 403; ansic: 149; makefile: 73
file content (26 lines) | stat: -rw-r--r-- 601 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
"""Wrapper for pproxy to fix Python 3.14 compatibility

Work around https://github.com/qwj/python-proxy/issues/200
"""

import sys
import asyncio
from typing import Any

from pproxy.server import main as main_  # type: ignore[import-untyped]


def main() -> Any:
    # Before Python 3.14 `get_event_loop()` used to create a new loop.
    # From Python 3.14 it raises a `RuntimeError`.
    try:
        asyncio.get_event_loop()
    except RuntimeError:
        asyncio.set_event_loop(asyncio.new_event_loop())

    return main_()


if __name__ == "__main__":
    sys.exit(main())