Skip to content

Fix python warnings about filehandles left open#297

Open
maartenboersma wants to merge 2 commits into
VLSIDA:devfrom
Aurora7913:close-filehandles
Open

Fix python warnings about filehandles left open#297
maartenboersma wants to merge 2 commits into
VLSIDA:devfrom
Aurora7913:close-filehandles

Conversation

@maartenboersma

Copy link
Copy Markdown
Contributor

We don't like python warnings, so we run with export PYTHONWARNINGS=error.

This floods the console with warnings like this.

ResourceWarning: unclosed file <_io.TextIOWrapper name='sram_1r1w_64x46/sram_1r1w_64x46.log' mode='a' encoding='UTF-8'>
Exception ignored in: <_io.FileIO name='sram_1r1w_64x46/sram_1r1w_64x46.log' mode='ab' closefd=True>
Traceback (most recent call last):
  File "../src/OpenRAM/compiler/debug.py", line 62, in print_raw
    log(str)

I found the problem (re-opening a file over and over again, never closing it) and fixed them by closing the filehandle after use.

Side recommendation: don't write your own logger infrastructure ever again. Others did it for you

@mguthaus

Copy link
Copy Markdown
Collaborator

OpenRAM was originally written in Python 2.x before there even was a decent logger. Thanks for your issue.

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

Successfully merging this pull request may close these issues.

2 participants