Skip to content

Commit

Permalink
Fix test_configure_logging_custom_handlers test for ARM (#2112)
Browse files Browse the repository at this point in the history
* Replace usage of `multiprocessing.Queue.qsize` with `multiprocessing.Queue.empty`, in the `_flush_logging_queue` helper method which was used by the `test_configure_logging_custom_handlers`.
* The `multiprocessing.Queue.qsize` method would raise a `NotImplementedError` on some platforms, notably linux/arm64 ref: https://docs.python.org/3.10/library/multiprocessing.html?highlight=queue#multiprocessing.Queue.qsize.

Closes #2110

## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/nv-morpheus/Morpheus/blob/main/docs/source/developer_guide/contributing.md).
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

Authors:
  - David Gardner (https://github.com/dagardner-nv)

Approvers:
  - Will Killian (https://github.com/willkill07)

URL: #2112
  • Loading branch information
dagardner-nv authored Jan 17, 2025
1 parent c40e355 commit cf8a9df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/morpheus/utils/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import logging
import logging.handlers
import os
import platform
import re
import time
from unittest.mock import patch
Expand All @@ -35,9 +34,12 @@


def _flush_logging_queue(logger: logging.Logger):
# Per Python documentation, the `empty` method is not reliable, adding a safety sleep
# https://docs.python.org/3.10/library/multiprocessing.html?highlight=queue#multiprocessing.Queue.empty
time.sleep(0.1)
for handler in logger.handlers:
if isinstance(handler, logging.handlers.QueueHandler):
while (handler.queue.qsize() != 0):
while (not handler.queue.empty()):
time.sleep(0.01)


Expand Down Expand Up @@ -131,8 +133,6 @@ def test_configure_logging_from_file_filenotfound():
configure_logging(log_config_file="does_not_exist.json")


@pytest.mark.skipif(platform.machine() == 'aarch64',
reason="Remove skip once https://github.com/nv-morpheus/Morpheus/issues/2110 is resolved")
def test_configure_logging_custom_handlers():
# Create a string stream for the handler
string_stream_1 = io.StringIO()
Expand Down

0 comments on commit cf8a9df

Please sign in to comment.