-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash while getting version when used alongside async frameworks #62
Comments
My opinion is that autover/Param.version should never call git for a deployed package. In practice that means the presence of .version or _version would shortcut any logic to do with git, simply returning the contents of that file. One problem is that currently various things we do as developers end up leaving such a file in our development branch, which will cause our development environment to misreport the version number. I think this problem can be avoided, and I consider it buggy if autover ever calls git in a distributed package, but I'm not sure @jlstevens agrees with me entirely. @jlstevens can chime in and propose an alternative solution if he has one... |
#58 would be the place to do that, I think. Meanwhile I think we should at least try to resolve things like complete crashes (particularly ones that are specific, repeatable, universal) as fast as we can - seems like solving these (even in imperfect ways) should trump other considerations. I.e. I want to help get #59 finished and resolve this issue, without distractions over whether git should be run at all (which has been an open issue since mid 2018). |
I suffer from the exact same problem... I've successfully manually patched Couldn't the fix be still included first (and shipped to users), and then any remaining follow-up work to fix tests be done subsequently? |
I am confident #66 would also fix this issue once we figure out how we want the Also the actual change to |
From @julioasotodv in holoviz/pyviz_comms#48:
In some weird environments, param's way of retrieving version information has many bugs (since it opens a subprocess to call git, for instance, which gives problems when Python processes are created with systems such as Supervisor or Gunicorn). This commit adds the option for the library to keep on going, even if the version cannot be correctly retreived.
Here are my steps to reproduce the failure: I was basically trying to use panel with the Bokeh Server, but having the Server embedded in a ASGI app (with Starlette, but that's irrelevant here), managed by Gunicorn with Uvicorn workers.
In a nutshell, imagine I create a file called
server.py
with the following code:And now, I want to run my "server application" with Gunicorn + Uvicorn workers (I have tried a couple of recent versions of both, so you can just
conda install gunicorn uvicorn
):The traceback for the error is:
The error happens in https://github.com/holoviz/param/blob/7d2d2a848dc79d9741709702f8b47f87497701b0/param/version.py#L247. It turns out that because of the way either Gunicorn or Uvicorn creates new python processes, for some reason the
output
argument in that method is an empty string''
, which makes the function fail. I believe this happens since the functiongit_fetch
in https://github.com/holoviz/param/blob/7d2d2a848dc79d9741709702f8b47f87497701b0/param/version.py#L169 has a value of its internaloutput
variable of''
, as the result of therun_cmd
function (which usessubprocess.Popen()
).I am doing some experiments, and it looks like the problem has to do with Gunicorn/Uvicorn returning zero for a
subprocess.Popen()
call that should return nonzero exit code in https://github.com/holoviz/param/blob/master/param/version.py#L23, so chances are thatparam.version
is not technicallly wrong...It turns out that param.version is running (or at least trying to run) some git commands in order to retrieve the version. The way the git commands are launched is through
subprocess.Popen()
as you can see here: https://github.com/holoviz/param/blob/7d2d2a848dc79d9741709702f8b47f87497701b0/param/version.py#L23And well, it turns out that
subprocess.Popen()
is nor particularly async-friendly when spawned from an os fork instruction (just like Gunicorn does). Apparently, one of the problems is that it misreports the return code for the launched command.The only solution I can think of would be to slightly modify the
run_cmd
function, to make it read the return code as either 0 if everything runs correctly; or nonzero if either the actual returncode read bysubprocess.Popen()
is nonzero or if the stderr is something other than an empty byte array.I can create a PR in param/autover to test this. It would solve my error, but I am unsure if it is a desirable solution at all for the rest of the world... Perhaps we can see if it Travis likes it?
The text was updated successfully, but these errors were encountered: