Skip to content

Commit 864f086

Browse files
authored
Fix bug in celery where works don't report data (#696)
This fixes Missing information from Celery workers when using MAX_TASKS_PER_CHILD issue. Previously, if celery was run with the --loglevel=INFO flag, an agent instance would be created for the main celery process and after the first worker shutdown, all following worker's agent instances would point to that agent instance instead of creating a new instance. This was root caused to incorrectly creating an agent instance when application activate was not set. Now no agent instance will be created for the main celery process.
1 parent 87b649f commit 864f086

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

newrelic/api/application.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def _instance(name, activate=True):
3333
if name is None:
3434
name = newrelic.core.config.global_settings().app_name
3535

36-
# Ensure we grab a reference to the agent before grabbing
37-
# the lock, else startup callback on agent initialisation
38-
# could deadlock as it tries to create a application when
39-
# we already have the lock held.
40-
41-
agent = newrelic.core.agent.agent_instance()
42-
4336
# Try first without lock. If we find it we can return.
4437

4538
instance = Application._instances.get(name, None)
4639

4740
if not instance and activate:
41+
# Ensure we grab a reference to the agent before grabbing
42+
# the lock, else startup callback on agent initialisation
43+
# could deadlock as it tries to create a application when
44+
# we already have the lock held.
45+
46+
agent = newrelic.core.agent.agent_instance()
47+
4848
with Application._lock:
4949
# Now try again with lock so that only one gets
5050
# to create and add it.

0 commit comments

Comments
 (0)