custom threadsafe sink hanging #3062
Replies: 4 comments 1 reply
-
What do you mean? something is wrong in your setup. Will it also hang “nb::gil_scoped_acquire acquire;” is removed? |
Beta Was this translation helpful? Give feedback.
-
There must be something not right with my setup, I used vcpkg in msvc and just noticed it was 1.12 and not 1.13 which I thought was odd. I'll clone the repository manually.
It will crash if I don't acquire the GIL. In a console I could just use std::cout and output directly from the cpp side but I need to output within a Jupyter notebook in which case I need to acquire the GIL. |
Beta Was this translation helpful? Give feedback.
-
Why? is it multi threaded? |
Beta Was this translation helpful? Give feedback.
-
So not finding basic_logger_mt was just a dumb mistake. I didn't realize it was a file logger and wasn't including the right header... Relating to the threading issue. It's feeling like a pretty tricky problem to navigate. I'm thinking it will be cleaner and less problematic if I just output to log files directly on the cpp side and avoid the Python Global Interpreter Lock and any other complications that could arise in any given Python environment. Thanks for the quick feedback on this. |
Beta Was this translation helpful? Give feedback.
-
I've created a custom sink to log data from multiple threads to a Python output but I think I must have something wrong because it will hang under certain conditions. I thought I should be using spdlog::basic_logger_mt as it states in the wiki but it doesn't appear available in the namespace.
Here is my definition of the sink and a function that initializes logging:
nb is nanobind, a Python bindings library (similar to nanobind). nb::print() invokes the Python print function.
Am missing something here?
Beta Was this translation helpful? Give feedback.
All reactions