Open lilin3 opened 6 years ago
ahhh, yes - I'm getting the same thing but it used to work perfectly fine before
Traceback (most recent call last):
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/tornado/ioloop.py", line 1208, in _run
return self.callback()
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/tornado/autoreload.py", line 182, in _reload_on_update
_check_file(modify_times, path)
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/tornado/autoreload.py", line 197, in _check_file
_reload()
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/tornado/autoreload.py", line 204, in _reload
fn()
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/livereload/server.py", line 310, in <lambda>
add_reload_hook(lambda: IOLoop.instance().close(all_fds=True))
File "/Users/johria/.local/share/virtualenvs/stories-f587eckA/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 65, in close
self.asyncio_loop.close()
File "/Users/johria/.pyenv/versions/3.6.3/lib/python3.6/asyncio/unix_events.py", line 63, in close
super().close()
File "/Users/johria/.pyenv/versions/3.6.3/lib/python3.6/asyncio/selector_events.py", line 107, in close
raise RuntimeError("Cannot close a running event loop")
RuntimeError: Cannot close a running event loop
see this related issue: https://github.com/tornadoweb/tornado/issues/1543
@lilin3 downgrading to 2.5.1 fixes the issue for me. @lepture looks like some regression in the latest release?
this seems like the PR that tries to close the event loop: https://github.com/lepture/python-livereload/pull/157
cc @wewearglasses
Reverting to 2.5.1 fixed this for me while trying to run a Flask server with livereload.
Is this still an issue?
Having the same issue, livereload version 2.6.3
with Python 3.9.0
on Windows 10 2004
(build 19041
)
Reverting to
2.5.1
fixed this for me while trying to run a Flask server with livereload.
Can confirm, works on this version. Didn't try other versions (apart from the latest 2.6.3
, which crashes).
pip freeze
This seem to still be an issue. Any resolution?
I dug into this issue yesterday a little and can confirm that @AlJohri is correct: https://github.com/lepture/python-livereload/pull/157/commits/26b1d85668f6805601ab0c5fbb4fbdf0581ca2ab is indeed the cause.
I'm not a Tornado or event loops in general expert but the docs state that
An IOLoop must be completely stopped before it can be closed. This means that IOLoop.stop() must be called and IOLoop.start() must be allowed to return before attempting to call IOLoop.close().
I tried calling IOLoop.instance().stop()
before calling close()
in the callback as a variation of
def close_loop():
IOLoop.instance().stop()
IOLoop.instance().close(all_fds=True)
add_reload_hook(close_loop)
IOLoop.instance().start()
but that didn't work as close_loop
(and therefore close()
) is called before IOLoop.instance().start()
can return which raises a RuntimeError
as well.
Removing IOLoop.instance().close(all_fds=True)
seems to work fine: Tornado restarts without errors, the browser reconnects and starts reacting to file changes. I don't experience/notice the "browser limbo in pending state" https://github.com/lepture/python-livereload/pull/157/commits/26b1d85668f6805601ab0c5fbb4fbdf0581ca2ab was supposed to fix.
I'm not sure whether this leaves dangling IOLoop
instances and/or results in memory leaks, though.
Hi @ndkv , if you are using python 3, the reload hook is not needed. I added that line of code in the paste when I was using python 2.
Yes, I'm on Python 3.
Do you know if it is still needed for Python 2?
Can we somehow fix this issue for Python 2 and 3?
I can confirm that this is still an issue for me as well. Just freshly installed livereload for my Django project and am getting the same error.
It is also affecting me on a Flask project.
Versions 2.5.2+ have this issue. Downgrade to version 2.5.1 (pip install livereload==2.5.1
).
I dug into this issue yesterday a little and can confirm that @AlJohri is correct: 26b1d85 is indeed the cause.
I'm not a Tornado or event loops in general expert but the docs state that
An IOLoop must be completely stopped before it can be closed. This means that IOLoop.stop() must be called and IOLoop.start() must be allowed to return before attempting to call IOLoop.close().
I tried calling
IOLoop.instance().stop()
before callingclose()
in the callback as a variation ofdef close_loop(): IOLoop.instance().stop() IOLoop.instance().close(all_fds=True) add_reload_hook(close_loop) IOLoop.instance().start()
but that didn't work as
close_loop
(and thereforeclose()
) is called beforeIOLoop.instance().start()
can return which raises aRuntimeError
as well.Removing
IOLoop.instance().close(all_fds=True)
seems to work fine: Tornado restarts without errors, the browser reconnects and starts reacting to file changes. I don't experience/notice the "browser limbo in pending state" 26b1d85 was supposed to fix.I'm not sure whether this leaves dangling
IOLoop
instances and/or results in memory leaks, though.
Latest still has this issue. Haven't had a chance to dig deep but this worked for me.
Versions 2.5.2+ have this issue. Downgrade to version 2.5.1 (
pip install livereload==2.5.1
).
It indeed does not show the error, but it also does not reload the browser tab.
--------------------------------above is error, follow is code------------------------------------------
the project is copied from another ubuntu computer, and is running correctly in another computer, almost everything is same between two computers, thanks for help