Skip to content

EOFError with pytest-xdist #54

@khaeru

Description

@khaeru

See hgrecco/flexcache#6. This occurs after the cache_folder argument here was added in #48:

# Use a registry cache
registry = pint.UnitRegistry(cache_folder=":auto:")

Code that uses iam-units and pytest-xdist together is affected. The error occurs sporadically/non-deterministically, depending on which xdist worker(s) are trying to write/read the cache file.

One way to resolve would be:

  1. Use an optional environment variable for the cache_folder, e.g.:
    registry = pint.UnitRegistry(cache_folder=os.environ.get("IAM_UNITS_CACHE", ":auto:"))
  2. In multiprocessing situations (such as with pytest-xdist), set a distinct value for this environment variable in each process.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions