AttributeError: 'Sanic' object has no attribute 'multiplexer'
TaylorHere opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
from sanic import Sanic
app = Sanic("demo")
app.m.restart(zero_downtime=True)
sanic app -d
Traceback (most recent call last):
File "/home/taylor/.local/bin/sanic", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/taylor/.local/lib/python3.11/site-packages/sanic/__main__.py", line 12, in main
cli.run(args)
File "/home/taylor/.local/lib/python3.11/site-packages/sanic/cli/app.py", line 106, in run
app = self._get_app(app_loader)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/taylor/.local/lib/python3.11/site-packages/sanic/cli/app.py", line 175, in _get_app
app = app_loader.load()
^^^^^^^^^^^^^^^^^
File "/home/taylor/.local/lib/python3.11/site-packages/sanic/worker/loader.py", line 78, in load
module = import_module(self.module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/tmp/app.py", line 4, in <module>
app.m.restart(zero_downtime=True)
^^^^^
File "/home/taylor/.local/lib/python3.11/site-packages/sanic/mixins/startup.py", line 116, in m
return self.multiplexer
^^^^^^^^^^^^^^^^
AttributeError: 'Sanic' object has no attribute 'multiplexer'
sanic 23.6.0
sanic-ext 23.6.0
sanic-routing 23.6.0
sanic-testing 23.6.0
Code snippet
from sanic import Sanic
app = Sanic("demo")
app.m.restart(zero_downtime=True)
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
Sanic 23.6.0; Routing 23.6.0
Additional context
No response
Can I work on this issue?
Can I work on this issue?
If you want to, I suggest you first write a test that fails then fix the problem seeing that the test also then passes, and make a PR. Be sure to mention this issue number with the PR. Everyone is welcome to make PRs here, and be sure to ask (especially @ahopkins) if it turns out to be too complicated.
From the code you showed, this is not a bug. You are trying to access the multiplexer in the global scope, which will never exist.
You can only access it from inside some sort of server-level handler. In a listener, middleware, route handler, etc.
this is the same error message as what happens on the healthcheck endpoint in our application