Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get Traceback Information when use subprocesses #2

Open
1 task done
bitranox opened this issue Nov 11, 2017 · 2 comments
Open
1 task done

get Traceback Information when use subprocesses #2

bitranox opened this issue Nov 11, 2017 · 2 comments
Assignees

Comments

@bitranox
Copy link
Owner

  • I'm submitting a ...
    • feature request

get Traceback information when use_signals=False, possibly by using tblib
(see https://pypi.python.org/pypi/tblib)

  • What is the current behavior?
    there is no Traceback Information when use_signals=False, because that cant be pickled from the process
    just the Exception is raised

  • What is the motivation / use case for changing the behavior?
    give correct traceback informaton for debugging

  • Please tell us about your environment:
    ALL

bitranox added a commit that referenced this issue Feb 25, 2019
@bitranox bitranox self-assigned this Feb 29, 2024
@bitranox bitranox changed the title get Traceback Information when use_signals=False get Traceback Information when use subprocesses Feb 29, 2024
@eponraj27392
Copy link

eponraj27392 commented Sep 27, 2024

@bitranox
I am facing the same issue here.
logger information is not available when i try to run the wrapper function concurrently (sub-process)
How can i make the logger and print information available ?

@bitranox
Copy link
Owner Author

To set up Python logging for subprocesses using a listener approach, you can use a logging configuration that allows each subprocess to send its log records to a listener running in the parent process. This is useful when you have multiple subprocesses and want them all to log in a coordinated way.

Here’s how you can set up a multiprocessing-safe logging configuration:

Step-by-Step Guide
Set up a logging listener in the parent process: The parent process runs a logging server that listens for logging messages from subprocesses.
Configure logging in subprocesses to send logs to the listener: Each subprocess sends its logging messages to the listener via a QueueHandler.

Listener in Parent Process: A QueueListener is set up in the parent process. It listens for log records that are sent from subprocesses via the log_queue.

Subprocess Logging: In each subprocess, we configure the logger to use a QueueHandler that forwards log messages to the log_queue. These messages are handled by the listener in the parent process.

QueueHandler: Used in each subprocess to send log records to a queue.
QueueListener: Used in the parent process to listen for log records from the queue and process them using the configured handlers.
multiprocessing.Queue: A queue that allows safe communication between processes.
This setup ensures that logs from all subprocesses are handled in a central location, which is helpful for debugging and monitoring parallel execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants