]> git.ipfire.org Git - thirdparty/starlette.git/commit
Add proper synchronisation to WebSocketTestSession (#2597)
authorOlocool17 <22843298+Olocool17@users.noreply.github.com>
Sat, 20 Jul 2024 09:06:51 +0000 (09:06 +0000)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 09:06:51 +0000 (03:06 -0600)
commit357a291aa61a813565139f8acafc0b8859f0c571
tree3b3cf24b4a1c1cab910d58702fd4cd81e74d89b9
parent5f57ef4eb1f2a249b1df6a8b6cdfed6197307f2b
Add proper synchronisation to WebSocketTestSession (#2597)

* Add proper synchronisation to WebSocketTestSession
`anyio.sleep(0)` is often used as a way to yield to another task.
However, depending on event loop implememtation it is not guaranteed to
actually do so in a timely manner.
This commit alters this behaviour in _asgi_receive by using
`anyio.Event`s as a simple synchronisation primitive, dramatically
speeding up the session depending on underlying system/implementation.

* Fix mypy type errors
Jinja 3.1.4 slightly changed the argument types of FileSystemLoader.

* Formatting

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
starlette/testclient.py