Skip to content

fix: remove ConnectorLoopError from connector.connect #1170

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 4 commits into from
Oct 2, 2024

Conversation

jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Oct 2, 2024

Python packages like gevent have monkey patching abilities and use greenlet
processes to replace synchronous code in an "asynchronous" fashion.

The ConnectorLoopError in connector.connect was put in as a safe-guard to try
and prevent improper async driver usage where users would accidentally call
connector.connect for asyncpg instead of calling connector.connect_async,
leading to an indefinite hang.

However, this error is preventing support for gevent which schedules tasks in
its greenlet threads.

Closes #969

@jackwotherspoon jackwotherspoon self-assigned this Oct 2, 2024
@jackwotherspoon jackwotherspoon requested a review from a team as a code owner October 2, 2024 16:20
@jackwotherspoon
Copy link
Collaborator Author

jackwotherspoon commented Oct 2, 2024

Originally added an integration test, but have since removed it as there seems to be no clean way to un-monkeypatch the modules afterwards... I have manually tested both gevent and eventlet now work.

@jackwotherspoon jackwotherspoon requested a review from enocom October 2, 2024 16:39
Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I confirmed this code works as expected when using gevent.

@jackwotherspoon jackwotherspoon merged commit a348659 into main Oct 2, 2024
15 checks passed
@jackwotherspoon jackwotherspoon deleted the remove-connect-loop-error branch October 2, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for gevent
3 participants