Skip to content

Commit

Permalink
Windows: fix event loop setting, fix backslashes, decrease timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 30, 2017
1 parent c049af5 commit 7d32a9a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -57,6 +57,9 @@
from nikola.utils import dns_sd, req_missing, get_logger, get_theme_path
LRJS_PATH = os.path.join(os.path.dirname(__file__), 'livereload.js')

if sys.platform == 'win32':
asyncio.set_event_loop(asyncio.ProactorEventLoop())


class CommandAuto(Command):
"""Automatic rebuilds for Nikola."""
Expand Down Expand Up @@ -179,11 +182,7 @@ def _execute(self, options, args):

# Prepare asyncio event loop
# Required for subprocessing to work
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
else:
loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop()

# Set debug setting
loop.set_debug(self.site.debug)
Expand Down Expand Up @@ -256,7 +255,7 @@ def _execute(self, options, args):
self.rebuild_queue.put((None, None))
loop.run_until_complete(srv.wait_closed())
loop.run_until_complete(webapp.shutdown())
loop.run_until_complete(handler.shutdown(60.0))
loop.run_until_complete(handler.shutdown(5.0))
loop.run_until_complete(webapp.cleanup())
self.wd_observer.stop()
self.wd_observer.join()
Expand Down Expand Up @@ -309,8 +308,8 @@ def reload_page(self, event):
# Move events have a dest_path, some editors like gedit use a
# move on larger save operations for write protection
event_path = event.dest_path if hasattr(event, 'dest_path') else event.src_path
self.logger.info('REFRESHING: {0}'.format(event_path))
p = os.path.relpath(event_path, os.path.abspath(self.site.config['OUTPUT_FOLDER']))
p = os.path.relpath(event_path, os.path.abspath(self.site.config['OUTPUT_FOLDER'])).replace(os.sep, '/')
self.logger.info('REFRESHING: {0}'.format(p))
yield from self.send_to_websockets({'command': 'reload', 'path': p, 'liveCSS': True})

@asyncio.coroutine
Expand Down

0 comments on commit 7d32a9a

Please sign in to comment.