| 1 |
###################################################################### |
| 2 |
# |
| 3 |
# File: test/integration/test_tqdm_closer.py |
| 4 |
# |
| 5 |
# Copyright 2023 Backblaze Inc. All Rights Reserved. |
| 6 |
# |
| 7 |
# License https://www.backblaze.com/using_b2_code.html |
| 8 |
# |
| 9 |
###################################################################### |
| 10 |
import re |
| 11 |
import sys |
| 12 |
|
| 13 |
import pytest |
| 14 |
|
| 15 |
|
| 16 |
@pytest.mark.skipif( |
| 17 |
(sys.platform != 'darwin') or ((sys.version_info.major, sys.version_info.minor) < (3, 11)), |
| 18 |
reason='Tqdm closing error only occurs on OSX and python 3.11 or newer', |
| 19 |
) |
| 20 |
def test_tqdm_closer(b2_tool, bucket, file_name): |
| 21 |
# test that stderr doesn't contain any warning, in particular warnings about multiprocessing resource tracker |
| 22 |
# leaking semaphores |
| 23 |
b2_tool.should_succeed([ |
| 24 |
'cat', |
| 25 |
f'b2://{bucket.name}/{file_name}', |
| 26 |
]) |
| 27 |
|
| 28 |
# test that disabling _TqdmCloser does produce a resource tracker warning. Should the following check ever fail, |
| 29 |
# that would mean that either Tqdm or python fixed the issue and _TqdmCloser can be disabled for fixed versions |
| 30 |
b2_tool.should_succeed( |
| 31 |
[ |
| 32 |
'cat', |
| 33 |
f'b2://{bucket.name}/{file_name}', |
| 34 |
], |
| 35 |
additional_env={'B2_TEST_DISABLE_TQDM_CLOSER': '1'}, |
| 36 |
expected_stderr_pattern=re.compile( |
| 37 |
r'UserWarning: resource_tracker: There appear to be \d+ leaked semaphore' |
| 38 |
r' objects to clean up at shutdown' |
| 39 |
), |
| 40 |
) |