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

Do not patch builtin classes #43

Closed
Lonami opened this issue Jun 9, 2019 · 1 comment
Closed

Do not patch builtin classes #43

Lonami opened this issue Jun 9, 2019 · 1 comment

Comments

@Lonami
Copy link

Lonami commented Jun 9, 2019

asyncio.StreamReader.read_ = lambda self: self.read(PACKET_SIZE)
asyncio.StreamReader.read_n = lambda self, n: asyncio.wait_for(self.readexactly(n), timeout=SOCKET_TIMEOUT)
asyncio.StreamReader.read_until = lambda self, s: asyncio.wait_for(self.readuntil(s), timeout=SOCKET_TIMEOUT)

It is very prone to breaking and should not be done. Consider sub-classing or making a proxy object instead. If anyone else were to do the same, this would break.

@qwj
Copy link
Owner

qwj commented Jun 10, 2019

This is a good suggestion. Patching builtin class is the easiest way to do this job, and pproxy is mostly used standalone.

@qwj qwj closed this as completed Jun 10, 2019
Lonami added a commit to LonamiWebs/Telethon that referenced this issue Jun 15, 2019
Although it supports a lot less features, aiosocks' code is much
cleaner, and python-proxy has several asyncio-related issues.

Furthermore, python-proxy author claims:

> "pproxy is mostly used standalone"
> (in qwj/python-proxy#43)
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

No branches or pull requests

2 participants