Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Is raven thread and process safe? #806

Open
@jinzhao1994

Description

@jinzhao1994

When I test it with multi process, my server does not receive any message. I try to find the reason. It seems that the message go to the Queue, but cannot be picked out. In fact, although I config handler for each process, they use the same handler and the same transport object. The worker object block at Queue.get method.

I config the handler like this in each process.

logger = logging.getLogger()
logger.handlers = []
client = Client(os.getenv('SENTRY_DSN'))
handler = SentryHandler(client)
handler.setLevel(logging.ERROR)
logger.addHandler(handler)

The worker object block at this statement.
File: raven/transport/threaded.py
Line 133, record = self._queue.get()

    def _target(self):
        while True:
            record = self._queue.get()  # This statement blocks.
            try:
                if record is self._terminator:
                    break
                callback, args, kwargs = record
                try:
                    callback(*args, **kwargs)
                except Exception:
                    logger.error('Failed processing job', exc_info=True)
            finally:
                self._queue.task_done()

            sleep(0)

Only the main process send the message successful.
Btw, because, my raven version is 5.2.0.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions