ddollar / forego

Foreman in Go
1.43k stars 176 forks source link

python output not displaying #62

Closed jdx closed 8 years ago

jdx commented 9 years ago

I think there is maybe a stdout flushing issue when using forego on windows. It doesn't display output from this django app: https://github.com/heroku/python-getting-started

C:\Users\IEUser\tmp\python-getting-started>type Procfile
web: python manage.py runserver 0.0.0.0:5000

C:\Users\IEUser\tmp\python-getting-started>forego start web
forego | starting web.1 on port 5000

C:\Users\IEUser\tmp\python-getting-started>python manage.py runserver 0.0.0.0:5000
July 08, 2015 - 15:01:47
Django version 1.8.1, using settings 'gettingstarted.settings'
Starting development server at http://0.0.0.0:5000/
Quit the server with CTRL-BREAK.
[08/Jul/2015 15:01:51]"GET / HTTP/1.1" 200 6525
[08/Jul/2015 15:01:51]"GET /static/lang-logo.png HTTP/1.1" 304 0

It still functions, but it doesn't display any output. After I press ctrl-c, it does show one line of output.

jdx commented 9 years ago

cc @kennethreitz

kron4eg commented 9 years ago

@dickeyxxx is it showing output under regular foreman?

jdx commented 9 years ago

yes it does

jamesbeith commented 9 years ago

I'm getting this same issue on OS X.

bgentry commented 9 years ago

@ddollar I feel like this is probably identical to an issue you fixed w/ Convox a while ago that's caused by python never outputting newlines

ddollar commented 9 years ago

Seems very likely I just don't have the bandwidth to fix it right now :)

jdx commented 9 years ago

mind elaborating more on what the issue was? I could take a pass at fixing it. btw expect more bug reports and forego usage, we switched to forego in all the Heroku documentation (via the heroku local command)

ddollar commented 9 years ago

In outlet.go it waits for a new line to display anything. Happy to give you a commit bit if you like.

kennethreitz commented 9 years ago

It's not that python doesn't "output" newlines, it's that Python doesn't flush stdout when it prints a newline. Most languages do.

brandonb927 commented 9 years ago

We stopped using forego after about an hour because of this issue :( Anything we can add to our django stack to allow us to use forego?

jdx commented 9 years ago

I'm trying to figure out how to get the subprocess to flush in order to fix this, but you might be able to fix this in your procfile by adding 2>&1 to the end of the command

ddollar commented 9 years ago

Set PYTHONUNBUFFERED to a non-empty string

https://docs.python.org/2/using/cmdline.html#envvar-PYTHONUNBUFFERED

jdx commented 9 years ago

PYTHONUNBUFFERED doesn't seem to work:

env PYTHONUNBUFFERED=0 forego start -f fixtures/python/Procfile
forego | starting out.1 on port 5000
out.1  | foo

here's the fixture I'm using: https://github.com/ddollar/forego/compare/master...dickeyxxx:python-sync?expand=1

that branch also fixes the problem, but I'm not sure it's the best solution

kennethreitz commented 9 years ago

PYTHONUNBUFFERED is for controlling python's pipe buffering, and while it can be useful on the consumption end of this problem (e.g. writing forego in python), it should have no effect on this.

The problem is that go is only printing lines when they are flushed, and python simply does not flush lines usually.

franciscolourenco commented 9 years ago

I'm also having problems getting proper stack traces from flask

franciscolourenco commented 8 years ago

My procfile:

web: gunicorn hello:app
dev: python hello.py

With forego start dev I don't get proper stack traces. With forego run python hello.py I get full stack trace.

Ruby foreman works fine in both cases. Aren't both commands supposed to have exactly the same result?

EDIT: The output: https://gist.github.com/aristidesfl/6a2127af781abb77ad9d EDIT2: Flask app with an error https://github.com/aristidesfl/forego-flask-stacktrace-example

ddollar commented 8 years ago

For now forego is going to assume that subprocesses flush their output regularly. If any Pythonistas want to take a swing at fixing this globally please feel free to submit a PR!