Skip to content

ValueError: I/O operation on closed file while running tests #78

@abhijeetkaurav1st

Description

@abhijeetkaurav1st

When we invoke command make test, it runs all the test successfully.
But produces logging error at the end.

Results (157.68s):
     202 passed
      68 deselected
--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1028, in emit
    stream.write(msg + self.terminator)
  File "/Users/abhijeet.kaurav/calm-dsl/venv/lib/python3.7/site-packages/colorama/ansitowin32.py", line 41, in write
    self.__convertor.write(text)
  File "/Users/abhijeet.kaurav/calm-dsl/venv/lib/python3.7/site-packages/colorama/ansitowin32.py", line 162, in write
    self.write_and_convert(text)
  File "/Users/abhijeet.kaurav/calm-dsl/venv/lib/python3.7/site-packages/colorama/ansitowin32.py", line 187, in write_and_convert
    self.write_plain_text(text, cursor, start)
  File "/Users/abhijeet.kaurav/calm-dsl/venv/lib/python3.7/site-packages/colorama/ansitowin32.py", line 195, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/Users/abhijeet.kaurav/calm-dsl/venv/lib/python3.7/site-packages/_pytest/capture.py", line 427, in write
    self.buffer.write(obj)
ValueError: I/O operation on closed file
Call stack:
  File "/Users/abhijeet.kaurav/calm-dsl/calm/dsl/db/handler.py", line 62, in close
    LOG.debug("Closing connection to local DB")
  File "/Users/abhijeet.kaurav/calm-dsl/calm/dsl/tools/logger.py", line 193, in debug
    return logger.debug(self.__add_caller_info(msg), *args, **kwargs)
Message: ':62] Closing connection to local DB'
Arguments: ()

Findings: This is producible because atexit handler is registered with db.close() method. And inside this method we are logging debug message Closing connection to local DB.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions