One of the most requested features is autoreloading aiohttp server on source file changes.
I never use the feature at all and don't have a strong personal feeling for adding it.
It may have negative effects by abnormal breaking opened connections (e.g. websockets) also.
But I see to many requests for the feature over internet for last months, so we need to implement it.
It's a easy task though.
This functionality is provided by aiohttp_utils already. Also it's possible to use watchdog (watchmedo) without writing any Python code :)
As, forgot. There is also --reload option for gunicorn which is works for me.
https://github.com/samuelcolvin/aiohttp_runserver
As I just explain on the mailing list I don't think it makes sense to include all the debug paraphernalia in aiohttp itself.
Whether it's this library or anther I think the should be a companion tool for aiohttp which help during development.
I built aiohttp-runserver after using gunicorn with --reload for a while and getting annoyed at it's logging (amount other things), particularly when you change the terminal window size!
@samuelcolvin just my two cents, but as someone who recently bet on using aiohttp in production, it would be a huge turn off for me if all of the debug and development tools are scattered around a bunch of small external repositories that may never get maintained.
unless it's a single other lib that's officially maintained and has all of the development tools, having a bunch of small libs these small libraries will lead to a typical node/reactjs style bootstrapping nightmare for new adopters. https://twitter.com/thomasfuchs/status/708675139253174273
The batteries included mentality of the python community is what made me choose aiohttp and not something built on top of node.
@ohsabry I've create a new issue #1156 addressing this very reasonable concern directly.
gunicorn --reload does not work immediately. it waits until the next timeout loop. any idea?
@mshahbazi have a try with aiohttp-devtools, it's still a work in progress but the runserver command is working well and has autoreload by default.
thank you for your reply and thank for the module. it looks great but I had the following problems:
I cannot figure out how does it work.
after installation, I got this error: cannot import name ‘StaticRoute'
I commented out the corresponding lines and still have problem with running my script.
let’s say I should run my script as: “aiohttp-runserver main.py” I get a long chain of errors, starting with:
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/aiohttp_runserver/serve.py", line 240, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
ImportError: No module named 'main'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/aiohttp/helpers.py", line 454, in log
self.logger.info(self._log_format % tuple(values), extra=extra)
File "/usr/lib/python3.5/logging/__init__.py", line 1279, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python3.5/logging/__init__.py", line 1415, in _log
self.handle(record)
File "/usr/lib/python3.5/logging/__init__.py", line 1425, in handle
self.callHandlers(record)
File "/usr/lib/python3.5/logging/__init__.py", line 1487, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.5/logging/__init__.py", line 855, in handle
self.emit(record)
File "/usr/local/lib/python3.5/dist-packages/aiohttp_runserver/logs.py", line 53, in emit
method, path, _, code, size = msg.split(' ')
ValueError: too many values to unpack (expected 5)
During handling of the above exception, another exception occurred:
…
to keep it simple, main.py holds the following codes only:
app = aiohttp.web.Application()
aiohttp.web.run_app(app=app, host=config.SERVER_HOST, port=config.SERVER_PORT, shutdown_timeout=1)
On Nov 28, 2016, at 2:21 PM, Samuel Colvin notifications@github.com wrote:
Have a try with aiohttp-devtools https://github.com/samuelcolvin/aiohttp-devtools, it's still a work in progress but the runserver command is working well and has autoreload by default.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/KeepSafe/aiohttp/issues/778#issuecomment-263240975, or mute the thread https://github.com/notifications/unsubscribe-auth/AGNhsGkbkPZuB1dKf6WbcNv1XK_eG2fzks5rCrI1gaJpZM4HZ5MC.
Hi @mshahbazi happy to help but please repost the question over on https://github.com/samuelcolvin/aiohttp-devtools to avoid even more confusion.
A few more details like OS and aiohttp version would be helpful too.
For me https://github.com/samuelcolvin/aiohttp-devtools is ready for use so this can be closed.
closing in favor of https://github.com/samuelcolvin/aiohttp-devtools
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a [new issue] for
related bugs.
If you feel like there's important points made in this discussion,
please include those exceprts into that [new issue].
Most helpful comment
@samuelcolvin just my two cents, but as someone who recently bet on using aiohttp in production, it would be a huge turn off for me if all of the debug and development tools are scattered around a bunch of small external repositories that may never get maintained.
unless it's a single other lib that's officially maintained and has all of the development tools, having a bunch of small libs these small libraries will lead to a typical node/reactjs style bootstrapping nightmare for new adopters. https://twitter.com/thomasfuchs/status/708675139253174273
The batteries included mentality of the python community is what made me choose
aiohttpand not something built on top of node.