Skip to content
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

Make Transport.connect a classmethod #389

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

orsinium
Copy link
Contributor

We have a number of places where we expect methods to be called in a specific order. It mostly concerns connect methods that are expected to be called as soon as the class is instantiated. You can find places like this by looking for assert self._something statements at the beginning of methods.

One such place is Transport which doesn't work if Transport.connect is not called first. The PR converts Transport.connect into a classmethod. So, now it's a constructor that returns an instantiated and connected Transport. It guarantees that any Transport instance is always connected. Well, or disconnected, but at least we can guarantee that TcpTransport._io_reader is never None.

@orsinium

This comment was marked as resolved.

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.

None yet

1 participant