Skip to content

Commit da8bcfd

Browse files
[3.14] gh-136394: Fix race condition in test_zstd (GH-136432) (GH-136506)
gh-136394: Fix race condition in test_zstd (GH-136432) (cherry picked from commit f519918) Co-authored-by: Rogdham <[email protected]>
1 parent 1346049 commit da8bcfd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/test_zstd.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,8 +2674,12 @@ def test_compress_locking(self):
26742674
input = b'a'* (16*_1K)
26752675
num_threads = 8
26762676

2677+
# gh-136394: the first output of .compress() includes the frame header
2678+
# we run the first .compress() call outside of the threaded portion
2679+
# to make the test order-independent
2680+
26772681
comp = ZstdCompressor()
2678-
parts = []
2682+
parts = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)]
26792683
for _ in range(num_threads):
26802684
res = comp.compress(input, ZstdCompressor.FLUSH_BLOCK)
26812685
if res:
@@ -2684,7 +2688,7 @@ def test_compress_locking(self):
26842688
expected = b''.join(parts) + rest1
26852689

26862690
comp = ZstdCompressor()
2687-
output = []
2691+
output = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)]
26882692
def run_method(method, input_data, output_data):
26892693
res = method(input_data, ZstdCompressor.FLUSH_BLOCK)
26902694
if res:

0 commit comments

Comments
 (0)