question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events are not sent with threaded transport using uWSGI with prefork

See original GitHub issue

Hi,

When trying to send events to the logging server with the default (threaded) transport mode and uWSGI as application server, the events are not sent provided the request is handled by a children spawned process.

Example :

The server : uwsgi --http :8080 --module conf.wsgi --home venv --process 2 --enable-threads

The log :

*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x26b9190 pid: 14124 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 14124, cores: 1)
spawned uWSGI worker 2 (pid: 14135, cores: 1)
[pid: 14124|app: 0|req: 1/1] 5.148.1.250 () {38 vars in 709 bytes} [Mon Mar 30 17:59:29 2015] GET /v1/crash/ => generated 227 bytes in 61 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)
[pid: 14135|app: 0|req: 1/2] 5.148.1.250 () {40 vars in 740 bytes} [Mon Mar 30 17:59:40 2015] GET /v1/crash/ => generated 227 bytes in 51 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)
[pid: 14124|app: 0|req: 2/3] 5.148.1.250 () {40 vars in 740 bytes} [Mon Mar 30 17:59:49 2015] GET /v1/crash/ => generated 227 bytes in 11 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)
[pid: 14135|app: 0|req: 2/4] 5.148.1.250 () {38 vars in 710 bytes} [Mon Mar 30 18:04:07 2015] GET /v1/crash/ => generated 227 bytes in 13 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)
[pid: 14124|app: 0|req: 3/5] 5.148.1.250 () {38 vars in 710 bytes} [Mon Mar 30 18:04:18 2015] GET /v1/crash/ => generated 227 bytes in 19 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)

Only 3 messages are sent to the server (the one being handled by PID 14124).

When terminating uWSGI :

Sentry is attempting to send 2 pending error messages
Waiting up to 10 seconds
Press Ctrl-C to quit

Other example : uwsgi --http :8080 --module conf.wsgi --home venv --process 3 --threads 2

Log :

*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x15781c0 pid: 14785 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 14785, cores: 2)
spawned uWSGI worker 2 (pid: 14797, cores: 2)
spawned uWSGI worker 3 (pid: 14798, cores: 2)

Same with --master (in this case nothing is send), or --emperor. Everything spawning processes prevent the messages from being sent. uWSGI v 2.0.10

This should be related to PR #583 though this does not fix the issue.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
luckydonaldcommented, Jan 20, 2017

I got away with using the non threaded sender class:

from raven.transport import HTTPTransport
client = raven.Client(transport=HTTPTransport)
0reactions
vova-ukrainecommented, Nov 21, 2017

You can force set sync HTTPTransport module as default transport module by Djnago settings:

RAVEN_CONFIG = {
    'dsn': '...',
    'transport': 'raven.transport.http.HTTPTransport'
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

uWSGI Documentation
If you start uWSGI without threads, the Python GIL will not be enabled, so threads generated by your application will never run.
Read more >
python - application run slowly under uwsgi threaded mode
when using prefork mode with workers setting 5, we get the request time is 10-20ms. but in threaded mode(one worker 5 threads), the...
Read more >
Configuring uWSGI for Production Deployment | Bloomberg LP
Running uWSGI in multithreading mode (with the threads options) will automatically enable threading support.
Read more >
Module Index - Apache HTTP Server Version 2.4
... Module implementing a hybrid multi-threaded multi-process web server ... LDAP directory to be used to store the database for HTTP Basic authentication....
Read more >
uWSGI Documentation - manualzz
By default sending the SIGTERM signal to uWSGI means “brutally reload the stack” while the convention is to shut an application down on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found