omergertel / pyformance

Performance metrics, based on Coda Hale's Yammer metrics
Other
195 stars 72 forks source link

CsvReporter does not close file handles after finishing #37

Closed RendijsSmukulis closed 7 years ago

RendijsSmukulis commented 7 years ago

There's currently no way to close the file handles opened by CsvReporter. This issue is demonstrated when running unit tests in a Windows environment:

python  "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pycharm\utrunner.py" C:\dev\git\pyformance\tests\test__csv_reporter.py true

Testing started at 11:50 PM ...

Error
Traceback (most recent call last):
  File "C:\dev\git\pyformance\tests\test__csv_reporter.py", line 27, in tearDown
    shutil.rmtree(self.path)
  File "C:\Users\Luuseens\pyenvs\pyformance\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\Luuseens\pyenvs\pyformance\lib\shutil.py", line 389, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\Luuseens\pyenvs\pyformance\lib\shutil.py", line 387, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\-\\AppData\\Local\\Temp\\tmpd295pp0o\\gauge1.csv'

Process finished with exit code 0