We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Celery inspect output JSON serialization is broken
# Checklist
- [ ] I have verified that the issue exists against the `master` branch of Celery.
- [ ] This has already been asked to the [discussion group](https://groups.google.com/forum/#!forum/celery-users) first.
- [x] I have read the relevant section in the
  [contribution guide](http://docs.celeryproject.org/en/latest/contributing.html#other-bugs)
  on reporting bugs.
- [x] I have checked the [issues list](https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22)
  for similar or identical bug reports.
- [x] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22)
  for existing proposed fixes.
- [ ] I have checked the [commit log](https://github.com/celery/celery/commits/master)
  to find out if the bug was already fixed in the master branch.
- [x] I have included all related issues and possible duplicate issues
  in this issue (If there are none, check this box anyway).

## Mandatory Debugging Information

- [ ] I have included the output of ``celery -A proj report`` in the issue.
    (if you are not able to do this, then at least specify the Celery
     version affected).
- [ ] I have verified that the issue exists against the `master` branch of Celery.
- [ ] I have included the contents of ``pip freeze`` in the issue.
- [ ] I have included all the versions of all the external dependencies required
  to reproduce this bug.

## Optional Debugging Information
- [ ] I have tried reproducing the issue on more than one Python version
  and/or implementation.
- [ ] I have tried reproducing the issue on more than one message broker and/or
  result backend.
- [ ] I have tried reproducing the issue on more than one version of the message
  broker and/or result backend.
- [ ] I have tried reproducing the issue on more than one operating system.
- [ ] I have tried reproducing the issue on more than one workers pool.
- [ ] I have tried reproducing the issue with autoscaling, retries,
  ETA/Countdown & rate limits disabled.
- [ ] I have tried reproducing the issue after downgrading
  and/or upgrading Celery and its dependencies.

## Environment & Settings
**Celery version**: 5.1.2 (sun-harmonics)

# Steps to Reproduce

Execute `celery -A proj inspect -j active`

# Expected Behavior
Valid JSON string is returned, like: 
```
{"worker-1": [], "worker-2": [], "worker-3": []}
```

# Actual Behavior
Command returns valid JSON in the first line, followed by double newline and some useless summary:
```
{"worker-1": [], "worker-2": [], "worker-3": []}

3 nodes online.
```
which makes the overall output an invalid JSON string.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `celery/bin/control.py`
Content:
```
1 """The ``celery control``, ``. inspect`` and ``. status`` programs."""
2 from functools import partial
3 
4 import click
5 from kombu.utils.json import dumps
6 
7 from celery.bin.base import (COMMA_SEPARATED_LIST, CeleryCommand,
8                              CeleryOption, handle_preload_options)
9 from celery.exceptions import CeleryCommandException
10 from celery.platforms import EX_UNAVAILABLE
11 from celery.utils import text
12 from celery.worker.control import Panel
13 
14 
15 def _say_remote_command_reply(ctx, replies, show_reply=False):
16     node = next(iter(replies))  # <-- take first.
17     reply = replies[node]
18     node = ctx.obj.style(f'{node}: ', fg='cyan', bold=True)
19     status, preply = ctx.obj.pretty(reply)
20     ctx.obj.say_chat('->', f'{node}{status}',
21                      text.indent(preply, 4) if show_reply else '',
22                      show_body=show_reply)
23 
24 
25 def _consume_arguments(meta, method, args):
26     i = 0
27     try:
28         for i, arg in enumerate(args):
29             try:
30                 name, typ = meta.args[i]
31             except IndexError:
32                 if meta.variadic:
33                     break
34                 raise click.UsageError(
35                     'Command {!r} takes arguments: {}'.format(
36                         method, meta.signature))
37             else:
38                 yield name, typ(arg) if typ is not None else arg
39     finally:
40         args[:] = args[i:]
41 
42 
43 def _compile_arguments(action, args):
44     meta = Panel.meta[action]
45     arguments = {}
46     if meta.args:
47         arguments.update({
48             k: v for k, v in _consume_arguments(meta, action, args)
49         })
50     if meta.variadic:
51         arguments.update({meta.variadic: args})
52     return arguments
53 
54 
55 @click.command(cls=CeleryCommand)
56 @click.option('-t',
57               '--timeout',
58               cls=CeleryOption,
59               type=float,
60               default=1.0,
61               help_group='Remote Control Options',
62               help='Timeout in seconds waiting for reply.')
63 @click.option('-d',
64               '--destination',
65               cls=CeleryOption,
66               type=COMMA_SEPARATED_LIST,
67               help_group='Remote Control Options',
68               help='Comma separated list of destination node names.')
69 @click.option('-j',
70               '--json',
71               cls=CeleryOption,
72               is_flag=True,
73               help_group='Remote Control Options',
74               help='Use json as output format.')
75 @click.pass_context
76 @handle_preload_options
77 def status(ctx, timeout, destination, json, **kwargs):
78     """Show list of workers that are online."""
79     callback = None if json else partial(_say_remote_command_reply, ctx)
80     replies = ctx.obj.app.control.inspect(timeout=timeout,
81                                           destination=destination,
82                                           callback=callback).ping()
83 
84     if not replies:
85         raise CeleryCommandException(
86             message='No nodes replied within time constraint',
87             exit_code=EX_UNAVAILABLE
88         )
89 
90     if json:
91         ctx.obj.echo(dumps(replies))
92     nodecount = len(replies)
93     if not kwargs.get('quiet', False):
94         ctx.obj.echo('\n{} {} online.'.format(
95             nodecount, text.pluralize(nodecount, 'node')))
96 
97 
98 @click.command(cls=CeleryCommand,
99                context_settings={'allow_extra_args': True})
100 @click.argument("action", type=click.Choice([
101     name for name, info in Panel.meta.items()
102     if info.type == 'inspect' and info.visible
103 ]))
104 @click.option('-t',
105               '--timeout',
106               cls=CeleryOption,
107               type=float,
108               default=1.0,
109               help_group='Remote Control Options',
110               help='Timeout in seconds waiting for reply.')
111 @click.option('-d',
112               '--destination',
113               cls=CeleryOption,
114               type=COMMA_SEPARATED_LIST,
115               help_group='Remote Control Options',
116               help='Comma separated list of destination node names.')
117 @click.option('-j',
118               '--json',
119               cls=CeleryOption,
120               is_flag=True,
121               help_group='Remote Control Options',
122               help='Use json as output format.')
123 @click.pass_context
124 @handle_preload_options
125 def inspect(ctx, action, timeout, destination, json, **kwargs):
126     """Inspect the worker at runtime.
127 
128     Availability: RabbitMQ (AMQP) and Redis transports.
129     """
130     callback = None if json else partial(_say_remote_command_reply, ctx,
131                                          show_reply=True)
132     arguments = _compile_arguments(action, ctx.args)
133     inspect = ctx.obj.app.control.inspect(timeout=timeout,
134                                           destination=destination,
135                                           callback=callback)
136     replies = inspect._request(action,
137                                **arguments)
138 
139     if not replies:
140         raise CeleryCommandException(
141             message='No nodes replied within time constraint',
142             exit_code=EX_UNAVAILABLE
143         )
144 
145     if json:
146         ctx.obj.echo(dumps(replies))
147     nodecount = len(replies)
148     if not ctx.obj.quiet:
149         ctx.obj.echo('\n{} {} online.'.format(
150             nodecount, text.pluralize(nodecount, 'node')))
151 
152 
153 @click.command(cls=CeleryCommand,
154                context_settings={'allow_extra_args': True})
155 @click.argument("action", type=click.Choice([
156     name for name, info in Panel.meta.items()
157     if info.type == 'control' and info.visible
158 ]))
159 @click.option('-t',
160               '--timeout',
161               cls=CeleryOption,
162               type=float,
163               default=1.0,
164               help_group='Remote Control Options',
165               help='Timeout in seconds waiting for reply.')
166 @click.option('-d',
167               '--destination',
168               cls=CeleryOption,
169               type=COMMA_SEPARATED_LIST,
170               help_group='Remote Control Options',
171               help='Comma separated list of destination node names.')
172 @click.option('-j',
173               '--json',
174               cls=CeleryOption,
175               is_flag=True,
176               help_group='Remote Control Options',
177               help='Use json as output format.')
178 @click.pass_context
179 @handle_preload_options
180 def control(ctx, action, timeout, destination, json):
181     """Workers remote control.
182 
183     Availability: RabbitMQ (AMQP), Redis, and MongoDB transports.
184     """
185     callback = None if json else partial(_say_remote_command_reply, ctx,
186                                          show_reply=True)
187     args = ctx.args
188     arguments = _compile_arguments(action, args)
189     replies = ctx.obj.app.control.broadcast(action, timeout=timeout,
190                                             destination=destination,
191                                             callback=callback,
192                                             reply=True,
193                                             arguments=arguments)
194 
195     if not replies:
196         raise CeleryCommandException(
197             message='No nodes replied within time constraint',
198             exit_code=EX_UNAVAILABLE
199         )
200 
201     if json:
202         ctx.obj.echo(dumps(replies))
203
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/celery/bin/control.py b/celery/bin/control.py
--- a/celery/bin/control.py
+++ b/celery/bin/control.py
@@ -144,6 +144,8 @@
 
     if json:
         ctx.obj.echo(dumps(replies))
+        return
+
     nodecount = len(replies)
     if not ctx.obj.quiet:
         ctx.obj.echo('\n{} {} online.'.format(

{"golden_diff": "diff --git a/celery/bin/control.py b/celery/bin/control.py\n--- a/celery/bin/control.py\n+++ b/celery/bin/control.py\n@@ -144,6 +144,8 @@\n \n     if json:\n         ctx.obj.echo(dumps(replies))\n+        return\n+\n     nodecount = len(replies)\n     if not ctx.obj.quiet:\n         ctx.obj.echo('\\n{} {} online.'.format(\n", "issue": "Celery inspect output JSON serialization is broken\n# Checklist\r\n- [ ] I have verified that the issue exists against the `master` branch of Celery.\r\n- [ ] This has already been asked to the [discussion group](https://groups.google.com/forum/#!forum/celery-users) first.\r\n- [x] I have read the relevant section in the\r\n  [contribution guide](http://docs.celeryproject.org/en/latest/contributing.html#other-bugs)\r\n  on reporting bugs.\r\n- [x] I have checked the [issues list](https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22)\r\n  for similar or identical bug reports.\r\n- [x] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22)\r\n  for existing proposed fixes.\r\n- [ ] I have checked the [commit log](https://github.com/celery/celery/commits/master)\r\n  to find out if the bug was already fixed in the master branch.\r\n- [x] I have included all related issues and possible duplicate issues\r\n  in this issue (If there are none, check this box anyway).\r\n\r\n## Mandatory Debugging Information\r\n\r\n- [ ] I have included the output of ``celery -A proj report`` in the issue.\r\n    (if you are not able to do this, then at least specify the Celery\r\n     version affected).\r\n- [ ] I have verified that the issue exists against the `master` branch of Celery.\r\n- [ ] I have included the contents of ``pip freeze`` in the issue.\r\n- [ ] I have included all the versions of all the external dependencies required\r\n  to reproduce this bug.\r\n\r\n## Optional Debugging Information\r\n- [ ] I have tried reproducing the issue on more than one Python version\r\n  and/or implementation.\r\n- [ ] I have tried reproducing the issue on more than one message broker and/or\r\n  result backend.\r\n- [ ] I have tried reproducing the issue on more than one version of the message\r\n  broker and/or result backend.\r\n- [ ] I have tried reproducing the issue on more than one operating system.\r\n- [ ] I have tried reproducing the issue on more than one workers pool.\r\n- [ ] I have tried reproducing the issue with autoscaling, retries,\r\n  ETA/Countdown & rate limits disabled.\r\n- [ ] I have tried reproducing the issue after downgrading\r\n  and/or upgrading Celery and its dependencies.\r\n\r\n## Environment & Settings\r\n**Celery version**: 5.1.2 (sun-harmonics)\r\n\r\n# Steps to Reproduce\r\n\r\nExecute `celery -A proj inspect -j active`\r\n\r\n# Expected Behavior\r\nValid JSON string is returned, like: \r\n```\r\n{\"worker-1\": [], \"worker-2\": [], \"worker-3\": []}\r\n```\r\n\r\n# Actual Behavior\r\nCommand returns valid JSON in the first line, followed by double newline and some useless summary:\r\n```\r\n{\"worker-1\": [], \"worker-2\": [], \"worker-3\": []}\r\n\r\n3 nodes online.\r\n```\r\nwhich makes the overall output an invalid JSON string.\n", "before_files": [{"content": "\"\"\"The ``celery control``, ``. inspect`` and ``. status`` programs.\"\"\"\nfrom functools import partial\n\nimport click\nfrom kombu.utils.json import dumps\n\nfrom celery.bin.base import (COMMA_SEPARATED_LIST, CeleryCommand,\n                             CeleryOption, handle_preload_options)\nfrom celery.exceptions import CeleryCommandException\nfrom celery.platforms import EX_UNAVAILABLE\nfrom celery.utils import text\nfrom celery.worker.control import Panel\n\n\ndef _say_remote_command_reply(ctx, replies, show_reply=False):\n    node = next(iter(replies))  # <-- take first.\n    reply = replies[node]\n    node = ctx.obj.style(f'{node}: ', fg='cyan', bold=True)\n    status, preply = ctx.obj.pretty(reply)\n    ctx.obj.say_chat('->', f'{node}{status}',\n                     text.indent(preply, 4) if show_reply else '',\n                     show_body=show_reply)\n\n\ndef _consume_arguments(meta, method, args):\n    i = 0\n    try:\n        for i, arg in enumerate(args):\n            try:\n                name, typ = meta.args[i]\n            except IndexError:\n                if meta.variadic:\n                    break\n                raise click.UsageError(\n                    'Command {!r} takes arguments: {}'.format(\n                        method, meta.signature))\n            else:\n                yield name, typ(arg) if typ is not None else arg\n    finally:\n        args[:] = args[i:]\n\n\ndef _compile_arguments(action, args):\n    meta = Panel.meta[action]\n    arguments = {}\n    if meta.args:\n        arguments.update({\n            k: v for k, v in _consume_arguments(meta, action, args)\n        })\n    if meta.variadic:\n        arguments.update({meta.variadic: args})\n    return arguments\n\n\n@click.command(cls=CeleryCommand)\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef status(ctx, timeout, destination, json, **kwargs):\n    \"\"\"Show list of workers that are online.\"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx)\n    replies = ctx.obj.app.control.inspect(timeout=timeout,\n                                          destination=destination,\n                                          callback=callback).ping()\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n    nodecount = len(replies)\n    if not kwargs.get('quiet', False):\n        ctx.obj.echo('\\n{} {} online.'.format(\n            nodecount, text.pluralize(nodecount, 'node')))\n\n\n@click.command(cls=CeleryCommand,\n               context_settings={'allow_extra_args': True})\n@click.argument(\"action\", type=click.Choice([\n    name for name, info in Panel.meta.items()\n    if info.type == 'inspect' and info.visible\n]))\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef inspect(ctx, action, timeout, destination, json, **kwargs):\n    \"\"\"Inspect the worker at runtime.\n\n    Availability: RabbitMQ (AMQP) and Redis transports.\n    \"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx,\n                                         show_reply=True)\n    arguments = _compile_arguments(action, ctx.args)\n    inspect = ctx.obj.app.control.inspect(timeout=timeout,\n                                          destination=destination,\n                                          callback=callback)\n    replies = inspect._request(action,\n                               **arguments)\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n    nodecount = len(replies)\n    if not ctx.obj.quiet:\n        ctx.obj.echo('\\n{} {} online.'.format(\n            nodecount, text.pluralize(nodecount, 'node')))\n\n\n@click.command(cls=CeleryCommand,\n               context_settings={'allow_extra_args': True})\n@click.argument(\"action\", type=click.Choice([\n    name for name, info in Panel.meta.items()\n    if info.type == 'control' and info.visible\n]))\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef control(ctx, action, timeout, destination, json):\n    \"\"\"Workers remote control.\n\n    Availability: RabbitMQ (AMQP), Redis, and MongoDB transports.\n    \"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx,\n                                         show_reply=True)\n    args = ctx.args\n    arguments = _compile_arguments(action, args)\n    replies = ctx.obj.app.control.broadcast(action, timeout=timeout,\n                                            destination=destination,\n                                            callback=callback,\n                                            reply=True,\n                                            arguments=arguments)\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n", "path": "celery/bin/control.py"}], "after_files": [{"content": "\"\"\"The ``celery control``, ``. inspect`` and ``. status`` programs.\"\"\"\nfrom functools import partial\n\nimport click\nfrom kombu.utils.json import dumps\n\nfrom celery.bin.base import (COMMA_SEPARATED_LIST, CeleryCommand,\n                             CeleryOption, handle_preload_options)\nfrom celery.exceptions import CeleryCommandException\nfrom celery.platforms import EX_UNAVAILABLE\nfrom celery.utils import text\nfrom celery.worker.control import Panel\n\n\ndef _say_remote_command_reply(ctx, replies, show_reply=False):\n    node = next(iter(replies))  # <-- take first.\n    reply = replies[node]\n    node = ctx.obj.style(f'{node}: ', fg='cyan', bold=True)\n    status, preply = ctx.obj.pretty(reply)\n    ctx.obj.say_chat('->', f'{node}{status}',\n                     text.indent(preply, 4) if show_reply else '',\n                     show_body=show_reply)\n\n\ndef _consume_arguments(meta, method, args):\n    i = 0\n    try:\n        for i, arg in enumerate(args):\n            try:\n                name, typ = meta.args[i]\n            except IndexError:\n                if meta.variadic:\n                    break\n                raise click.UsageError(\n                    'Command {!r} takes arguments: {}'.format(\n                        method, meta.signature))\n            else:\n                yield name, typ(arg) if typ is not None else arg\n    finally:\n        args[:] = args[i:]\n\n\ndef _compile_arguments(action, args):\n    meta = Panel.meta[action]\n    arguments = {}\n    if meta.args:\n        arguments.update({\n            k: v for k, v in _consume_arguments(meta, action, args)\n        })\n    if meta.variadic:\n        arguments.update({meta.variadic: args})\n    return arguments\n\n\n@click.command(cls=CeleryCommand)\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef status(ctx, timeout, destination, json, **kwargs):\n    \"\"\"Show list of workers that are online.\"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx)\n    replies = ctx.obj.app.control.inspect(timeout=timeout,\n                                          destination=destination,\n                                          callback=callback).ping()\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n    nodecount = len(replies)\n    if not kwargs.get('quiet', False):\n        ctx.obj.echo('\\n{} {} online.'.format(\n            nodecount, text.pluralize(nodecount, 'node')))\n\n\n@click.command(cls=CeleryCommand,\n               context_settings={'allow_extra_args': True})\n@click.argument(\"action\", type=click.Choice([\n    name for name, info in Panel.meta.items()\n    if info.type == 'inspect' and info.visible\n]))\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef inspect(ctx, action, timeout, destination, json, **kwargs):\n    \"\"\"Inspect the worker at runtime.\n\n    Availability: RabbitMQ (AMQP) and Redis transports.\n    \"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx,\n                                         show_reply=True)\n    arguments = _compile_arguments(action, ctx.args)\n    inspect = ctx.obj.app.control.inspect(timeout=timeout,\n                                          destination=destination,\n                                          callback=callback)\n    replies = inspect._request(action,\n                               **arguments)\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n        return\n\n    nodecount = len(replies)\n    if not ctx.obj.quiet:\n        ctx.obj.echo('\\n{} {} online.'.format(\n            nodecount, text.pluralize(nodecount, 'node')))\n\n\n@click.command(cls=CeleryCommand,\n               context_settings={'allow_extra_args': True})\n@click.argument(\"action\", type=click.Choice([\n    name for name, info in Panel.meta.items()\n    if info.type == 'control' and info.visible\n]))\n@click.option('-t',\n              '--timeout',\n              cls=CeleryOption,\n              type=float,\n              default=1.0,\n              help_group='Remote Control Options',\n              help='Timeout in seconds waiting for reply.')\n@click.option('-d',\n              '--destination',\n              cls=CeleryOption,\n              type=COMMA_SEPARATED_LIST,\n              help_group='Remote Control Options',\n              help='Comma separated list of destination node names.')\n@click.option('-j',\n              '--json',\n              cls=CeleryOption,\n              is_flag=True,\n              help_group='Remote Control Options',\n              help='Use json as output format.')\n@click.pass_context\n@handle_preload_options\ndef control(ctx, action, timeout, destination, json):\n    \"\"\"Workers remote control.\n\n    Availability: RabbitMQ (AMQP), Redis, and MongoDB transports.\n    \"\"\"\n    callback = None if json else partial(_say_remote_command_reply, ctx,\n                                         show_reply=True)\n    args = ctx.args\n    arguments = _compile_arguments(action, args)\n    replies = ctx.obj.app.control.broadcast(action, timeout=timeout,\n                                            destination=destination,\n                                            callback=callback,\n                                            reply=True,\n                                            arguments=arguments)\n\n    if not replies:\n        raise CeleryCommandException(\n            message='No nodes replied within time constraint',\n            exit_code=EX_UNAVAILABLE\n        )\n\n    if json:\n        ctx.obj.echo(dumps(replies))\n", "path": "celery/bin/control.py"}]}