From 64414a3b7d62e22b089cc3801c7ea3602b70e565 Mon Sep 17 00:00:00 2001 From: jeanluciano Date: Wed, 15 Jan 2025 15:02:52 -0600 Subject: [PATCH 1/4] Switchs drain all call to new thread --- src/prefect/logging/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefect/logging/handlers.py b/src/prefect/logging/handlers.py index 0e254a9e58a9..1aa071d254f8 100644 --- a/src/prefect/logging/handlers.py +++ b/src/prefect/logging/handlers.py @@ -108,7 +108,7 @@ def flush(cls): # Not ideal, but this method is called by the stdlib and cannot return a # coroutine so we just schedule the drain in the global loop thread and continue - from_sync.call_soon_in_loop_thread(create_call(APILogWorker.drain_all)) + from_sync.call_soon_in_new_thread(create_call(APILogWorker.drain_all)) return None else: # We set a timeout of 5s because we don't want to block forever if the worker From 9e97343a50da0f0fbc786887894f8d50c8575a13 Mon Sep 17 00:00:00 2001 From: jeanluciano Date: Thu, 16 Jan 2025 12:18:34 -0600 Subject: [PATCH 2/4] integration test added --- flows/setup_logging.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 flows/setup_logging.py diff --git a/flows/setup_logging.py b/flows/setup_logging.py new file mode 100644 index 000000000000..e77fa38a0194 --- /dev/null +++ b/flows/setup_logging.py @@ -0,0 +1,20 @@ +import logging +from logging.config import dictConfig + +from prefect import flow + +logger = logging.getLogger(__name__) +logger.setLevel("WARNING") + +dictConfig({"version": 1, "incremental": False}) + + +@flow +def myflow(): + return "Hello" + + +if __name__ == "__main__": + result = myflow() + + assert result == "Hello" From 5a4a5b373037d3a852eeb1785329d437499dd3f6 Mon Sep 17 00:00:00 2001 From: jeanluciano Date: Thu, 16 Jan 2025 13:39:14 -0600 Subject: [PATCH 3/4] updates doc string --- flows/setup_logging.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flows/setup_logging.py b/flows/setup_logging.py index e77fa38a0194..0223e90e2a78 100644 --- a/flows/setup_logging.py +++ b/flows/setup_logging.py @@ -1,3 +1,7 @@ +""" +This is a regression tests for https://github.com/PrefectHQ/prefect/issues/16115 +""" + import logging from logging.config import dictConfig From d61af8a8b8fa31e0208c3aecde095a7870bfa2bb Mon Sep 17 00:00:00 2001 From: jeanluciano Date: Thu, 16 Jan 2025 16:56:15 -0600 Subject: [PATCH 4/4] updates doc comment --- src/prefect/logging/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefect/logging/handlers.py b/src/prefect/logging/handlers.py index 1aa071d254f8..a8323cff6f5b 100644 --- a/src/prefect/logging/handlers.py +++ b/src/prefect/logging/handlers.py @@ -107,7 +107,7 @@ def flush(cls): ) # Not ideal, but this method is called by the stdlib and cannot return a - # coroutine so we just schedule the drain in the global loop thread and continue + # coroutine so we just schedule the drain in a new thread and continue from_sync.call_soon_in_new_thread(create_call(APILogWorker.drain_all)) return None else: