File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,14 @@ def patch_app(app, pin=None):
1818 """Attach the Pin class to the application and connect
1919 our handlers to Celery signals.
2020 """
21+ if getattr (app , '__datadog_patch' , False ):
22+ return
23+ setattr (app , '__datadog_patch' , True )
24+
25+ # attach the PIN object
2126 pin = pin or Pin (service = WORKER_SERVICE , app = APP , app_type = AppTypes .worker )
2227 pin .onto (app )
23-
28+ # connect to the Signal framework
2429 signals .task_prerun .connect (trace_prerun )
2530 signals .task_postrun .connect (trace_postrun )
2631 signals .before_task_publish .connect (trace_before_publish )
@@ -33,6 +38,10 @@ def unpatch_app(app):
3338 """Remove the Pin instance from the application and disconnect
3439 our handlers from Celery signal framework.
3540 """
41+ if not getattr (app , '__datadog_patch' , False ):
42+ return
43+ setattr (app , '__datadog_patch' , False )
44+
3645 pin = Pin .get_from (app )
3746 if pin is not None :
3847 delattr (app , _DD_PIN_NAME )
You can’t perform that action at this time.
0 commit comments