@@ -264,51 +264,6 @@ def run(self, *args, **kwargs):
264
264
wrapped_task .__module__ = CeleryTaskWrapper .__module__
265
265
266
266
return wrapped_task
267
-
268
-
269
- # # This will not work with the current version of Celery
270
- # # This only gets called during the async execution of a task
271
- # # and the task is wrapped later in the process to accomodate
272
- # # custom task classes.
273
- # def wrap_Celery_send_task(wrapped, instance, args, kwargs):
274
- # transaction = current_transaction()
275
- # if not transaction:
276
- # return wrapped(*args, **kwargs)
277
-
278
- # # Merge distributed tracing headers into outgoing task headers
279
- # try:
280
- # dt_headers = MessageTrace.generate_request_headers(transaction)
281
- # original_headers = kwargs.get("headers", None)
282
- # if dt_headers:
283
- # if not original_headers:
284
- # kwargs["headers"] = dict(dt_headers)
285
- # else:
286
- # kwargs["headers"] = dt_headers = dict(dt_headers)
287
- # dt_headers.update(dict(original_headers))
288
- # except Exception:
289
- # pass
290
-
291
- # return wrapped(*args, **kwargs)
292
-
293
-
294
- def wrap_worker_optimizations (wrapped , instance , args , kwargs ):
295
- # Attempt to uninstrument BaseTask before stack protection is installed or uninstalled
296
- try :
297
- from celery .app .task import BaseTask
298
-
299
- if isinstance (BaseTask .__call__ , _NRBoundFunctionWrapper ):
300
- BaseTask .__call__ = BaseTask .__call__ .__wrapped__
301
- except Exception :
302
- BaseTask = None
303
-
304
- # Allow metaprogramming to run
305
- result = wrapped (* args , ** kwargs )
306
-
307
- # Rewrap finalized BaseTask
308
- if BaseTask : # Ensure imports succeeded
309
- BaseTask .__call__ = CeleryTaskWrapper (BaseTask .__call__ )
310
-
311
- return result
312
267
313
268
314
269
def instrument_celery_local (module ):
@@ -319,11 +274,6 @@ def instrument_celery_local(module):
319
274
module .Proxy .__call__ = CeleryTaskWrapper (module .Proxy .__call__ )
320
275
321
276
322
- # def instrument_celery_app_base(module):
323
- # if hasattr(module, "Celery") and hasattr(module.Celery, "send_task"):
324
- # wrap_function_wrapper(module, "Celery.send_task", wrap_Celery_send_task)
325
-
326
-
327
277
def instrument_celery_worker (module ):
328
278
if hasattr (module , "process_initializer" ):
329
279
# We try and force activation of the agent before
@@ -367,13 +317,6 @@ def force_agent_shutdown(*args, **kwargs):
367
317
368
318
369
319
def instrument_celery_app_trace (module ):
370
- # Uses same wrapper for setup and reset worker optimizations to prevent patching and unpatching from removing wrappers
371
- if hasattr (module , "setup_worker_optimizations" ):
372
- wrap_function_wrapper (module , "setup_worker_optimizations" , wrap_worker_optimizations )
373
-
374
- if hasattr (module , "reset_worker_optimizations" ):
375
- wrap_function_wrapper (module , "reset_worker_optimizations" , wrap_worker_optimizations )
376
-
377
320
if hasattr (module , "build_tracer" ):
378
321
wrap_function_wrapper (module , "build_tracer" , wrap_build_tracer )
379
322
0 commit comments