ganga-devs / ganga

Ganga is an easy-to-use frontend for job definition and management
GNU General Public License v3.0
100 stars 159 forks source link

Running unit tests throw logging error #2302

Open dg1223 opened 8 months ago

dg1223 commented 8 months ago

Running unit tests on local machine throws logging error. Tests run successfully. No other side effects.

I believe the Logging error occurs because of an IO error when ShutdownManager.py tries to use the default Python logger. Ganga is unable to store the test logs probably because it is trying to access an already closed file.

Run tests

python -m pytest ganga/GangaCore/test/Unit

Output

================================================================================ test session starts ================================================================================
platform linux -- Python 3.8.5, pytest-8.0.2, pluggy-1.4.0 -- /home/[redacted]/ganga/gangaenv/bin/python3
cachedir: .pytest_cache
rootdir: /home/[redacted]/ganga
configfile: setup.cfg
plugins: mock-3.12.0, cov-4.1.0, pylint-0.21.0
collected 141 items                                                                                                                                                                 

ganga/GangaCore/test/Unit/Credentials/TestCredentialInfo.py::Unit.Credentials.TestCredentialInfo.FakeShell PASSED                                                             [  0%]
...
ganga/GangaCore/test/Unit/Utility/TestUtilitiesVirtualizationInstallUDocker.py::TestInstallUDocker::test_installUDocker_success PASSED                                        [100%]

=============================================================================== 141 passed in 41.52s ================================================================================
--- Logging error ---
Traceback (most recent call last):
  File "/home/[redacted]/anaconda3/lib/python3.8/logging/__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 46, in _protected_ganga_exitfuncs
    _unprotected_ganga_exitfuncs()
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 113, in _unprotected_ganga_exitfuncs
    logger.info("Stopping Job processing before shutting down Repositories")
Message: 'Stopping Job processing before shutting down Repositories'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File "/home/[redacted]/anaconda3/lib/python3.8/logging/__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 46, in _protected_ganga_exitfuncs
    _unprotected_ganga_exitfuncs()
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 120, in _unprotected_ganga_exitfuncs
    logger.info("Shutting Down Ganga Repositories")
Message: 'Shutting Down Ganga Repositories'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File "/home/[redacted]/anaconda3/lib/python3.8/logging/__init__.py", line 1084, in emit
    stream.write(msg + self.terminator)
ValueError: I/O operation on closed file.
Call stack:
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 46, in _protected_ganga_exitfuncs
    _unprotected_ganga_exitfuncs()
  File "/home/[redacted]/ganga/ganga/GangaCore/Core/InternalServices/ShutdownManager.py", line 121, in _unprotected_ganga_exitfuncs
    Repository_runtime.shutdown()
  File "/home/[redacted]/ganga/ganga/GangaCore/Runtime/Repository_runtime.py", line 181, in shutdown
    logger.info('Registry Shutdown')
Message: 'Registry Shutdown'
Arguments: ()