Skip to content

fix event loop for windows #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/postgres_mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import asyncio
import sys

from . import server
from . import top_queries


def main():
"""Main entry point for the package."""
# As of version 3.3.0 Psycopg on Windows is not compatible with the default
# ProactorEventLoop.
# See: https://www.psycopg.org/psycopg3/docs/advanced/async.html#async
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

asyncio.run(server.main())


Expand Down
4 changes: 0 additions & 4 deletions src/postgres_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,3 @@ async def shutdown(sig=None):

# Exit with appropriate status code
sys.exit(128 + sig if sig is not None else 0)


if __name__ == "__main__":
asyncio.run(main())