thanethomson / httpwatcher

Python-based HTTP server for static files with live reload
MIT License
20 stars 10 forks source link

Event loop error in tornado v5 #1

Closed epatters closed 5 years ago

epatters commented 5 years ago

I'm using httpwatcher via statik. After upgrading to tornado v5, I get the following error when a file modification is detected:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/epatters/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/watchdog/observers/api.py", line 199, in run
    self.dispatch_events(self.event_queue, self.timeout)
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/watchdog/observers/api.py", line 368, in dispatch_events
    handler.dispatch(event)
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/watchdog/events.py", line 322, in dispatch
    self.on_any_event(event)
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/httpwatcher/filesystem.py", line 95, in on_any_event
    self.watcher.track_event(event)
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/httpwatcher/filesystem.py", line 60, in track_event
    self.fs_event_queue.put(event)
  File "/Users/epatters/Local/website-env/lib/python3.6/site-packages/tornado/queues.py", line 180, in put
    future = Future()
  File "/Users/epatters/anaconda3/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/Users/epatters/anaconda3/lib/python3.6/asyncio/events.py", line 602, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-1'.
thanethomson commented 5 years ago

You're absolutely right - it appears as though Tornado 5+ causes this issue at present. In the meantime, I've pushed v0.5.2 of httpwatcher to restrict to Tornado 4.xx. Will look into supporting Tornado 5+ ASAP.

Specifically for Statik usage, until Statik's dependencies are updated, the following should do the trick:

> pip uninstall httpwatcher
> pip install "httpwatcher==0.5.2"