Skip to content

Commit 2d3968a

Browse files
authored
fix event loop for windows (#67)
* fix event loop for windows
1 parent c6c0010 commit 2d3968a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/postgres_mcp/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import asyncio
2+
import sys
23

34
from . import server
45
from . import top_queries
56

67

78
def main():
89
"""Main entry point for the package."""
10+
# As of version 3.3.0 Psycopg on Windows is not compatible with the default
11+
# ProactorEventLoop.
12+
# See: https://www.psycopg.org/psycopg3/docs/advanced/async.html#async
13+
if sys.platform == "win32":
14+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
15+
916
asyncio.run(server.main())
1017

1118

src/postgres_mcp/server.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,3 @@ async def shutdown(sig=None):
618618

619619
# Exit with appropriate status code
620620
sys.exit(128 + sig if sig is not None else 0)
621-
622-
623-
if __name__ == "__main__":
624-
asyncio.run(main())

0 commit comments

Comments
 (0)