abingham / traad

An JSON+HTTP server for the rope Python refactoring library
MIT License
107 stars 20 forks source link

Flush stderr after writing server status #101

Closed JackCrawley closed 6 years ago

JackCrawley commented 6 years ago

I was running into a (rather fatal) problem where these prints to stderr were not showing up:

_stderr("Bottle v%s server starting up (using %s)...\n" % (__version__, repr(server)))
_stderr("Listening on http://%s:%d/\n" % (server.host, server.port))
_stderr("Hit Ctrl-C to quit.\n\n")

Emacs-traad relies on these lines being printed when launching a server. Since they were not printing, emacs-traad would time out whenever a command was issued, rendering it non-functional. (Spacemacs, Windows 10, fresh install of Traad and emacs-traad.)

Turns out the lines were being run, but _stderr was buffering the output. As a result, emacs-traad couldn't read the output - at least until something else caused a buffer flush (e.g. logging something). Forcing a flush after the output is sent to _stderr fixes the problem.

abingham commented 6 years ago

Thanks! You might consider a PR for the bottle project itself. This may not be a problem with current releases; the one I took is quite old.

JackCrawley commented 6 years ago

Good idea, I'll take a look. Thanks for merging!