Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? FileNotFound on cleanup #46

Open
jmrgibson opened this issue Dec 9, 2020 · 3 comments
Open

Bug? FileNotFound on cleanup #46

jmrgibson opened this issue Dec 9, 2020 · 3 comments

Comments

@jmrgibson
Copy link

jmrgibson commented Dec 9, 2020

Neat plugin, great docs. I'm running into the following issue, outlined below:

Scenario:

  • pytest 6.0.1
  • pytest-harvest 1.10.0
  • pytest-xdist 2.0.0
  • running via a shiv
  • running multiple instances of pytest simultaneously

stacktrace:

  File "/home/builduser/.shiv/pytest_f6cdbae7-eadd-41ab-aef2-dd73926c7212/site-packages/pytest_harvest/plugin.py", line 435, in pytest_harvest_xdist_cleanup
    rmtree(self.results_path)
  File "/usr/lib/python3.7/shutil.py", line 485, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/lib/python3.7/shutil.py", line 483, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '.xdist_harvested'

How is self.results_path generated? it it unique per process? or would it be shared if I was running two copies of pytest simultaneously, thus leading to the following error?

EDIT: I should probably mention I'm only using the following hook in my root conftest.py

def pytest_sessionfinish(session):
    """ Gather all results and save them to a csv.
    Works both on worker and master nodes, and also with xdist disabled"""

    session_results_df = get_session_results_df(session)
    suffix = 'all' if is_main_process(session) else get_xdist_worker_id(session)
    session_results_df.to_csv('results_%s.csv' % suffix)
@smarie
Copy link
Owner

smarie commented Dec 10, 2020

Hi @jmrgibson, thanks for submitting this issue ! Indeed results_path is not unique per process:

class DefaultXDistHarvester(object):

That is currently documented here: https://smarie.github.io/python-pytest-harvest/#pytest-x-dist

We'll probably need to change this. Do you have an alternative in mind ? Maybe as simple as appending os.getpid() to that path ?

@jmrgibson
Copy link
Author

jmrgibson commented Dec 10, 2020 via email

@smarie
Copy link
Owner

smarie commented Dec 10, 2020

This seems like a viable alternative. However I am concerned with debugging. Most users won't be aware that this temp dir is created behind the scenes, and therefore will not be able to perform a bit of debugging themselves by inspecting the files created inside.

Even if this is less elegant, is there any drawback that you might see with appending the process number to this dir name ?

I'm trying to weight one against the other... puzzling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants