Skip to content

Commit 7764138

Browse files
committed
don't explode if uwsgi isn't started in master mode (#446)
closes #446
1 parent eed06a8 commit 7764138

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44
[Check the diff](https://github.com/elastic/apm-agent-python/compare/v4.2.1...master)
55
* fixed an issue with Celery and the prefork worker pool (#444)
6+
* fixed an issue when running uwsgi without a master process (#446)
67

78
## v4.2.1
89
[Check the diff](https://github.com/elastic/apm-agent-python/compare/v4.2.0...v4.2.1)

elasticapm/utils/compat.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,17 @@ def multidict_to_dict(d):
170170

171171

172172
try:
173-
from uwsgidecorators import postfork
173+
import uwsgi
174+
175+
# check if a master is running before importing postfork
176+
if uwsgi.masterpid() != 0:
177+
from uwsgidecorators import postfork
178+
else:
179+
180+
def postfork(f):
181+
return f
182+
183+
174184
except ImportError:
175185

176186
def postfork(f):

0 commit comments

Comments
 (0)