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

Green leaves empty temp files in /tmp #228

Closed
lcerman opened this issue Jul 13, 2020 · 5 comments
Closed

Green leaves empty temp files in /tmp #228

lcerman opened this issue Jul 13, 2020 · 5 comments

Comments

@lcerman
Copy link
Contributor

lcerman commented Jul 13, 2020

After running green an empty tmpdir remain in /tmp for each test file executed. E.g., if I have project with 10 test files, 10 empty directories remains after running green. In a larger project it soon reaches thousands of empty directories in tmp after a while...

Steps to reproduce:

  1. create testfile.py:
import unittest

class Test(unittest.TestCase):
    def test(self):
        pass
  1. run green testfile.py

An empty tmp* directory is left in /tmp.

Our green config file:

verbose = 2
file-pattern = *_test.py
omit-patterns = *_test.py
$ green --version
Green 3.2.0, Coverage 5.1, Python 3.7.5

Note: when running the test with standard unittest module no empty dir remains, it seems to be issue of green not unittest module.

@lcerman
Copy link
Contributor Author

lcerman commented Jul 14, 2020

I have just found that the temp dirs are intentionally not removed by the poolRunner when the Python 3 is detected. Also found one older attempt to fix this here #173.

If that is problem of macOS why not narrow the condition skipping temp removal for macOS only? Leaving thousands of empty temp directories after multiple runs of the tests is somewhat annoying...

CleanCut added a commit that referenced this issue Aug 10, 2020
…eaks many versions of Python 3 on Linux and macOS.

This reverts commit 14d360b.
@CleanCut
Copy link
Owner

@lcerman It's extremely annoying. Unfortunately, it's also disturbingly hard to fix. I've spent days on this in the past. Take a look at what happens if I just try to naively clean up files and ignore errors --> 💥 ... and not just on macOS.

Perhaps it just needs a fresh pair of eyes! Would you like to give it a try? We all have our blind spots, so maybe you'll find a way that I missed. If you fork and make a PR, any commit you push to your fork should trigger CI on TravisCI and AppVeyor so you can see whether anything breaks or not.

image

@lcerman
Copy link
Contributor Author

lcerman commented Oct 6, 2020

Finally, I am back with a solution: #232

The solution is pragmatic -- rather than trying to remove the temp-dirs in the workers a single temp-dir is created by the main function. The workers continue to create their own temps as sub-directories of the main temp, which is then removed when the main function finishes.

@CleanCut
Copy link
Owner

Awesome! Thank you so much. That's a nice solution.

@CleanCut
Copy link
Owner

The fix is included in 3.2.3, just released.

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