Aymeric Augustin

Results 368 comments of Aymeric Augustin

I declared these constants as class variables because, somehow, I know that someone would want to adjust them, even if that involved a private API :-) FYI I expected the...

In case someone else has the same need -- please leave a comment and I'm likely to reopen the issue! The request for a public API is legitimate, even if...

`import websockets` barely imports anything because websockets includes an automatic, on-demand import mechanism to optimize memory usage. Accessing `websockets.connect` triggers the import of the asyncio client and all its dependencies....

OK, that's unexpected. Note that benchmarking with task manager is quite crude: it tells your how much memory the system gave to Python, but not how much Python is actually...

Here's a version instrumented with tracemalloc: ```python import asyncio import random import tracemalloc from websockets import connect async def main(): async def startWebsocket(): await asyncio.sleep(random.randint(0, 20)) #add some delay so...

If you want to benchmark websockets vs. asyncio, you could open TLS connections to echo.websocket.org; probably you would get similar memory usage to what you're getting with websockets.

Taking a fresh look at the tracemalloc output this morning, I located the culprit. asyncio's SSLProtocol pre-allocates a read buffer: https://github.com/python/cpython/blob/46cbdf967ada11b0286060488b61635fd6a2bb23/Lib/asyncio/sslproto.py#L278 The default size that buffer is 256kB: https://github.com/python/cpython/blob/46cbdf967ada11b0286060488b61635fd6a2bb23/Lib/asyncio/sslproto.py#L264 256kB...

Interesting. That being said, unless you are really memory constrained, I recommend sticking with the default event loop on Windows, as it's expected to have better I/O performance.

That's a valid feature request. Which server are you using? `websockets.asyncio.server.serve`?