Skip to content

port-target-cache not available with pytest-xdist (RDT-1277) #354

@hfudev

Description

@hfudev

https://github.com/espressif/esp-bsp/actions/runs/14508751792/job/40703558008

[gw10] linux -- Python 3.11.12 /usr/local/bin/python3.11
/usr/local/lib/python3.11/site-packages/pytest_embedded/plugin.py:630: in port_target_cache
    with shelve.open(_cache_file_path) as f:
/usr/local/lib/python3.11/shelve.py:243: in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
/usr/local/lib/python3.11/shelve.py:227: in __init__
    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
/usr/local/lib/python3.11/dbm/__init__.py:95: in open
    return mod.open(file, flag, mode)
E   _gdbm.error: [Errno 11] Resource temporarily unavailable: '/tmp/pytest-embedded/pytest-embedded-cache/port_target_cache'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.11/site-packages/pytest_embedded/plugin.py:[63](https://github.com/espressif/esp-bsp/actions/runs/14508751792/job/40703558008#step:8:64)3: in port_target_cache
    os.remove(_cache_file_path)
E   FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-embedded/pytest-embedded-cache/port_target_cache'

For now, the port_target_cache is held for the entire process. Let's change it to be read and written on-demand, using a file lock. Since pytest-xdist runs tests with multiprocessing, standard multiprocessing.Lock or threading.Lock won't work.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions