diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-11-06 16:45:03 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-11-06 16:45:03 +0300 |
commit | 78599f0d3f71953914880138fcfcdd929951fd07 (patch) | |
tree | 209166bf93ef885cc7a65afb8ec26203b93cbb29 /test/test_asgi_application.py | |
parent | 2220b8258f116d12f9cf6eb4133f41ec374b75f5 (diff) | |
download | unit-78599f0d3f71953914880138fcfcdd929951fd07.tar.gz unit-78599f0d3f71953914880138fcfcdd929951fd07.tar.bz2 |
Tests: fixing racing condition in ASGI threads test.
ASGI threads read all the requests from the queue before start processing it.
This why test need to wait a little to let the ASGI thread start request
processing and block. In virtual environment any thread or process may
be delayed and only method to avoid racing is a reasonable sleep increase.
Diffstat (limited to 'test/test_asgi_application.py')
-rw-r--r-- | test/test_asgi_application.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/test_asgi_application.py b/test/test_asgi_application.py index 179a69ee..b382e2f2 100644 --- a/test/test_asgi_application.py +++ b/test/test_asgi_application.py @@ -406,16 +406,16 @@ Connection: close self.load('threads') assert 'success' in self.conf( - '4', 'applications/threads/threads' - ), 'configure 4 threads' + '2', 'applications/threads/threads' + ), 'configure 2 threads' socks = [] - for i in range(4): + for i in range(2): (_, sock) = self.get( headers={ 'Host': 'localhost', - 'X-Delay': '2', + 'X-Delay': '3', 'Connection': 'close', }, no_recv=True, @@ -424,7 +424,7 @@ Connection: close socks.append(sock) - time.sleep(0.25) # required to avoid greedy request reading + time.sleep(1.0) # required to avoid greedy request reading threads = set() |