Pytest fails: Too many open files

I have faced a very strange issue:
when I run our python test-cases with pytest, it starts to fails with the log below stating that too many files are open.

I have googled around, but haven’t found any solution and don’t have any glue what causes this behavioral

Can anybody help me (even if you need further information, please let me know).

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>pytest -vvvv --setup-show tests
=========================================================================================== test session starts ===========================================================================================
platform linux -- Python 3.8.10, pytest-8.3.2, pluggy-1.5.0 -- <path>/.env/bin/python3
cachedir: .pytest_cache
rootdir: <path>
plugins: cov-5.0.0
collected 135 items / 3 errors
================================================================================================= ERRORS ==================================================================================================
________________________________________________________________________ ERROR collecting tests/functional/test_user_functional.py ________________________________________________________________________
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
???
<frozen importlib._bootstrap>:991: in _find_and_load
???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:671: in _load_unlocked
???
.env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:165: in exec_module
source_stat, co = _rewrite_test(fn, self.config)
.env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:343: in _rewrite_test
source = fn.read_bytes()
/usr/lib/python3.8/pathlib.py:1229: in read_bytes
???
/usr/lib/python3.8/pathlib.py:1222: in open
???
/usr/lib/python3.8/pathlib.py:1078: in _opener
???
E OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py'
____________________________________________________________________________________ ERROR collecting tests/test_data _____________________________________________________________________________________
.env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call
result: TResult | None = func()
.env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect
return list(collector.collect())
.env/lib/python3.8/site-packages/_pytest/main.py:523: in collect
for direntry in scandir(self.path):
.env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir
with os.scandir(path) as s:
E OSError: [Errno 24] Too many open files: '<path>/test_data'
_______________________________________________________________________________________ ERROR collecting tests/unit _______________________________________________________________________________________
.env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call
result: TResult | None = func()
.env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect
return list(collector.collect())
.env/lib/python3.8/site-packages/_pytest/main.py:523: in collect
for direntry in scandir(self.path):
.env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir
with os.scandir(path) as s:
E OSError: [Errno 24] Too many open files: '<path>/unit'
============================================================================================ warnings summary =============================================================================================
.env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201
<path>/.env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201: UserWarning: Field name "schema" in "SnowflakeConnectModel" shadows an attribute in parent "BaseModel"
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================================= short test summary info =========================================================================================
ERROR tests/functional/test_user_functional.py - OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py'
ERROR tests/test_data - OSError: [Errno 24] Too many open files: '<path>/test_data'
ERROR tests/unit - OSError: [Errno 24] Too many open files: '<path>/unit'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================================================================== 1 warning, 3 errors in 3.06s =======================================================================================
</code>
<code>pytest -vvvv --setup-show tests =========================================================================================== test session starts =========================================================================================== platform linux -- Python 3.8.10, pytest-8.3.2, pluggy-1.5.0 -- <path>/.env/bin/python3 cachedir: .pytest_cache rootdir: <path> plugins: cov-5.0.0 collected 135 items / 3 errors ================================================================================================= ERRORS ================================================================================================== ________________________________________________________________________ ERROR collecting tests/functional/test_user_functional.py ________________________________________________________________________ /usr/lib/python3.8/importlib/__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) <frozen importlib._bootstrap>:1014: in _gcd_import ??? <frozen importlib._bootstrap>:991: in _find_and_load ??? <frozen importlib._bootstrap>:975: in _find_and_load_unlocked ??? <frozen importlib._bootstrap>:671: in _load_unlocked ??? .env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:165: in exec_module source_stat, co = _rewrite_test(fn, self.config) .env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:343: in _rewrite_test source = fn.read_bytes() /usr/lib/python3.8/pathlib.py:1229: in read_bytes ??? /usr/lib/python3.8/pathlib.py:1222: in open ??? /usr/lib/python3.8/pathlib.py:1078: in _opener ??? E OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py' ____________________________________________________________________________________ ERROR collecting tests/test_data _____________________________________________________________________________________ .env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call result: TResult | None = func() .env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect return list(collector.collect()) .env/lib/python3.8/site-packages/_pytest/main.py:523: in collect for direntry in scandir(self.path): .env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir with os.scandir(path) as s: E OSError: [Errno 24] Too many open files: '<path>/test_data' _______________________________________________________________________________________ ERROR collecting tests/unit _______________________________________________________________________________________ .env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call result: TResult | None = func() .env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect return list(collector.collect()) .env/lib/python3.8/site-packages/_pytest/main.py:523: in collect for direntry in scandir(self.path): .env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir with os.scandir(path) as s: E OSError: [Errno 24] Too many open files: '<path>/unit' ============================================================================================ warnings summary ============================================================================================= .env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201 <path>/.env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201: UserWarning: Field name "schema" in "SnowflakeConnectModel" shadows an attribute in parent "BaseModel" -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================================= short test summary info ========================================================================================= ERROR tests/functional/test_user_functional.py - OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py' ERROR tests/test_data - OSError: [Errno 24] Too many open files: '<path>/test_data' ERROR tests/unit - OSError: [Errno 24] Too many open files: '<path>/unit' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ====================================================================================== 1 warning, 3 errors in 3.06s ======================================================================================= </code>
pytest -vvvv --setup-show tests
=========================================================================================== test session starts ===========================================================================================
platform linux -- Python 3.8.10, pytest-8.3.2, pluggy-1.5.0 -- <path>/.env/bin/python3
cachedir: .pytest_cache
rootdir: <path>
plugins: cov-5.0.0
collected 135 items / 3 errors                                                                                                                                                                            

================================================================================================= ERRORS ==================================================================================================
________________________________________________________________________ ERROR collecting tests/functional/test_user_functional.py ________________________________________________________________________
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
.env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:165: in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
.env/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:343: in _rewrite_test
    source = fn.read_bytes()
/usr/lib/python3.8/pathlib.py:1229: in read_bytes
    ???
/usr/lib/python3.8/pathlib.py:1222: in open
    ???
/usr/lib/python3.8/pathlib.py:1078: in _opener
    ???
E   OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py'
____________________________________________________________________________________ ERROR collecting tests/test_data _____________________________________________________________________________________
.env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call
    result: TResult | None = func()
.env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect
    return list(collector.collect())
.env/lib/python3.8/site-packages/_pytest/main.py:523: in collect
    for direntry in scandir(self.path):
.env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir
    with os.scandir(path) as s:
E   OSError: [Errno 24] Too many open files: '<path>/test_data'
_______________________________________________________________________________________ ERROR collecting tests/unit _______________________________________________________________________________________
.env/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call
    result: TResult | None = func()
.env/lib/python3.8/site-packages/_pytest/runner.py:389: in collect
    return list(collector.collect())
.env/lib/python3.8/site-packages/_pytest/main.py:523: in collect
    for direntry in scandir(self.path):
.env/lib/python3.8/site-packages/_pytest/pathlib.py:885: in scandir
    with os.scandir(path) as s:
E   OSError: [Errno 24] Too many open files: '<path>/unit'
============================================================================================ warnings summary =============================================================================================
.env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201
  <path>/.env/lib/python3.8/site-packages/pydantic/_internal/_fields.py:201: UserWarning: Field name "schema" in "SnowflakeConnectModel" shadows an attribute in parent "BaseModel"

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================================= short test summary info =========================================================================================
ERROR tests/functional/test_user_functional.py - OSError: [Errno 24] Too many open files: '<path>/functional/test_user_functional.py'
ERROR tests/test_data - OSError: [Errno 24] Too many open files: '<path>/test_data'
ERROR tests/unit - OSError: [Errno 24] Too many open files: '<path>/unit'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
====================================================================================== 1 warning, 3 errors in 3.06s =======================================================================================

ulimit output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 29053
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 29053
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
</code>
<code>ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 29053 max locked memory (kbytes, -l) 65536 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 29053 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited </code>
ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 29053
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 29053
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật