@list_route(methods=["<STR_LIT>"])<EOL><INDENT>def active_status(self, request):<DEDENT>
app_installed = "<STR_LIT>" in settings.INSTALLED_APPS<EOL>if not app_installed:<EOL><INDENT>return Response(status=status.HTTP_501_NOT_IMPLEMENTED)<EOL><DEDENT>from djcelery.models import WorkerState<EOL>count_workers = WorkerState.objects.all().count()<EOL>result = self.inspect.active()<EOL>if result is not None and count_workers == len(result):<EOL><INDENT>return Response(status=status.HTTP_200_OK)<EOL><DEDENT>return Response(status=status.HTTP_404_NOT_FOUND)<EOL>
This will only work if you have django-celery installed (for now).
In case you only need to work with status codes to find out if the
workers are up or not.
This will only work if we assume our db only contains "active workers".
To use this feature, you must ensure you use only named workers,
For example: "-n worker1@localhost:8000".
http://docs.celeryproject.org/en/latest/userguide/workers.html#starting-the-worker