1

Environment:

  • Python: 3.4
  • Celery: 4.1.0
  • Flower: 0.9.0
  • Centos: 7.0

    --persistent flag is used. Celery version v4.1.0.

If I create a couple of tasks, they run as expected.

After I send a SIGINT:

[D 150923 14:43:09 events:96] Saving state to 'flower'...
[D 150923 14:43:09 events:97] <State: events=54 tasks=4>

The DB file 'flower' clearly contains the correct data. When I start flower again:

[D 150923 14:47:35 events:76] Loading state from 'flower'...
[D 150923 14:47:35 events:80] <State: events=0 tasks=0>

If I run Python and load the file with shelve:

> f['events']
> <State: events=0 tasks=0>

So, something isn't working correctly when shelve reads the file.

Yannick
  • 813
  • 8
  • 17
Dave
  • 11
  • 3

1 Answers1

0

I ran into the same issue. It looks like celery's State.__repr__ method prints the event_count and task_count attribtues.

From https://github.com/celery/celery/blob/v4.1.0/celery/events/state.py

R_STATE = '<State: events={0.event_count} tasks={0.task_count}>'
....
def __repr__(self):
    return R_STATE.format(self)

However, event_count and task_count are not included in the pickled form, which means those attributes will default to 0 when the contents are read back from the db. From the same file:

def __reduce__(self):
    return self.__class__, (
        self.event_callback, self.workers, self.tasks, None,
        self.max_workers_in_memory, self.max_tasks_in_memory,
        self.on_node_join, self.on_node_leave,
        _serialize_Task_WeakSet_Mapping(self.tasks_by_type),
        _serialize_Task_WeakSet_Mapping(self.tasks_by_worker),
)

You'll notice that when persistence is enabled, the tasks listed in flowers "Tasks" view will persist across flower restarts, which shows the state is being read in correctly from the db.

MicGer
  • 305
  • 4
  • 8