micropython-lib/uasyncio
Paul Sokolovsky f704ac5817 uasyncio: StreamReader: Separate "poll socket" vs "I/O socket".
Poll socket is what's passed to uselect.poll(), while I/O socket is what's
used for .read(). This is a workaround of the issue that MicroPython doesn't
support proxying poll functionality for stream wrappers (like SSL, websocket,
etc.)
This issue is tracked as https://github.com/micropython/micropython/issues/3394

It may be that it's more efficient to apply such a workaround on uasyncio
level rather than implementing full solution of uPy side.
2017-11-05 18:01:21 +02:00
..
benchmark uasyncio: test_http_server_heavy: Close socket with "finally". 2017-11-05 17:46:50 +02:00
uasyncio uasyncio: StreamReader: Separate "poll socket" vs "I/O socket". 2017-11-05 18:01:21 +02:00
README.rst
README.test
example_http_client.py
example_http_server.py
metadata.txt uasyncio: Release 1.2.4. 2017-11-05 17:52:15 +02:00
setup.py uasyncio: Release 1.2.4. 2017-11-05 17:52:15 +02:00
test_echo.py
test_io_starve.py
test_readexactly.py
test_readline.py

README.test

Testing and Validating
----------------------

To test uasyncio correctness and performance, HTTP server samples can be
used. The simplest test is with test_http_server.py and Apache Benchmark
(ab). In one window, run:

micropython -O test_http_server.py

(-O is needed to short-circuit debug logging calls.)

In another:

ab -n10000 -c10 http://localhost:8081/

ab tests that all responses have the same length, but doesn't check
content. test_http_server.py also serves very short, static reply.


For more heavy testing, test_http_server_heavy.py is provided. It serves
large response split among several async writes. It is also dynamic -
includes incrementing counter, so each response will be different. The
response size generates is more 4Mb, because under Linux, socket writes
can buffer up to 4Mb of content (this appear to be controlled by
/proc/sys/net/ipv4/tcp_wmem and not /proc/sys/net/core/wmem_default).
test_http_server_heavy.py also includes (trivial) handling of
client-induced errors like EPIPE and ECONNRESET. To validate content
served, a post-hook script for "boom" tool
(https://github.com/tarekziade/boom) is provided.

Before start, you may want to bump .listen() value in uasyncio/__init__.py
from default 10 to at least 30.

Start:

micropython -X heapsize=300000000 -O test_http_server_heavy.py

(Yes, that's 300Mb of heap - we'll be serving 4+Mb of content with 30
concurrent connections).

And:

PYTHONPATH=. boom -n1000 -c30 http://localhost:8081 --post-hook=boom_uasyncio.validate

There should be no Python exceptions in the output.