File handling bug on PyPy (4.0 regression it seems)

Issue #411 resolved
Ionel Cristian Mărieș created an issue

It appears that on PyPy coverage will randomly fail to load data files. I suspect there's improper file handling somewhere (implicit close instead of using .close() or context manager api).


I had even more failed builds like those but they passed after rerun - which leads me to the conclusion that coverage don't properly handle file closing.

Comments (10)

  1. Ned Batchelder repo owner

    My own test suite occasionally prints a warning during the PyPy tests about unclosed files, but I have never been able to track it down. I just checked all of the uses of open(), and they all seem solid to me. If you can find one to fix, I'm happy to do it.

  2. Ionel Cristian Mărieș reporter

    Now that I think more about it, I think it's something related to atexit module. Does coverage register any handlers that flush files there?

  3. Ned Batchelder repo owner

    Yes, it uses atexit() to save data to the data file. Shouldn't that work on PyPy?

  4. Ionel Cristian Mărieș reporter

    Yes, it looks like 3.7 also make empty files (still investigating that).

    Meanwhile, can we change 4.0 to allow merging empty files, just like 3.7?

  5. Ionel Cristian Mărieș reporter

    My bad, turns out I was sending SIGTERM to the process just as it was existing (eg: it was running atexit funcs).

    Not sure now if it's worth allowing empty coverage files. Close if you want.

  6. Log in to comment