Issue 1:
I have a very time-sensitive application that I'm building.

I noticed that the first time a worker sends a new task, it has a non-trivial delay due to the declaring of the queues.

I would like to know if it's possible to remove this delay, or to move it at some init function in my worker.

Related Issues and Possible Duplicates

None found

Related Issues

None found

Possible Duplicates

None

Environment & Settings

Celery version: 4.2.1 (windowlicker)

celery report Output:

software -> celery:4.2.1 (windowlicker) kombu:4.4.0 py:3.6.6
billiard:3.5.0.5 redis:3.2.0
platform -> system:Darwin arch:64bit imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:disabled

broker_url: 'redis://localhost:6379//'

Steps to Reproduce

Required Dependencies

Minimal Python Version: N/A or Unknown

Minimal Broker Version: N/A or Unknown

Minimal Result Backend Version: N/A or Unknown

Minimal OS and/or Kernel Version: N/A or Unknown

Minimal Broker Client Version: N/A or Unknown

Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==2.4.2
billiard==3.5.0.5
celery==4.2.1
kombu==4.4.0
pytz==2018.9
redis==3.2.0
vine==1.2.0

Other Dependencies

N/A

Minimally Reproducible Test Case

import time

from celery import Celery

app = Celery('test', broker='redis://localhost:6379')

@app.task()
def dummy_task_secondary():
print("Dummy task completed")

@app.task()
def dummy_task_primary():
t = time.time()
dummy_task_secondary.delay()
print(f"First time it took {time.time() - t}")

t = time.time()
dummy_task_secondary.delay()
print(f"Second time it took {time.time() - t}")

Expected Behavior

There is no difference between the time it takes to send the first task and the second.

Actual Behavior

The first time is dramatically slower:

[2019-03-11 15:27:42,610: WARNING/ForkPoolWorker-8] First time it took 0.029098987579345703
[2019-03-11 15:27:42,612: WARNING/ForkPoolWorker-8] Second time it took 0.0007290840148925781

Issue 2:
I am not sure if this issue is a feature request or a request for guidance. I do not see how this could be accomplished, so I guess it is a feature request -- but perhaps it is already possible?

I am trying to swap from using class based tasks to decorator tasks. Simple tasks are easy to swap over. However, some of my tasks are based around this class based task: https://github.com/PolicyStat/jobtastic/blob/v2.1.1/jobtastic/task.py#L313

The Jobtastic Task Class provides a run method that prevents duplicate tasks from running simultaneously and abstracts some cruft that is pretty handy. Then its run method calls calculate_result() to perform the actual work of the task you create.

What has been holding this back is since the decorator makes your function the run method, how can I implement this functionality without rewriting it in every task? If the run() method of the Jobtastic Task is overridden, the utility of the task is lost.

Is there a way to incorporate the advanced runtime logic of the Jobtastic Task? Is it possible to tell the decorator what method the wrapped function should become? Or would an additional run() wrapper be required to handle this with a decorated approach?