pserve run in a child process under Fabric/Invoke + VirtualEnv ?

15 views
Skip to first unread message

Jonathan Vanasco

unread,
Jun 8, 2022, 4:31:12 PM6/8/22
to pylons-discuss
I doubt anyone here may have experienced this, but I've run out of resources to explore on this...

We use Fabric (fabfile.org) to automate a lot of things. It is great.

I built a new routine in it this week, and I can't get it to clean up properly.  The routine simply spins up an admin version of a pyramid app, then hits some API endpoints to POST some filesystem data to it.

This is executed in a virtualenv. The problematic part of the routine is roughly...

@task
def import_data(c):
    with c.cd("localpath/to/pyramid_app"):
        proc_server = c.run("pserve dev_admin.ini", replace_env=False, asynchronous=True)

The issue is that I see two different processes on the operating system:
* cd localpath/to/pyramid_app && pserve dev_admin.ini
* /Library/Frameworks...Python /virtualenv/bin/pserve dev_admin.ini

asynchronous is used because running pyramid would otherwise block forever.  i just analyze the process stderr for the "Serving" line, and continue once it is emitted. 

In fabric, I can access the FIRST process via `proc_server.runner` and I can stop/kill/terminate that -- but that leaves the second process running.  That second process is one PID higher, and is the actual process that is running Pyramid and bound to the ports.  

I have a temporary workaround where I increase the PID by 1 and `c.run("kill %s" % pid2)` that process, but this is janky.

Has anyone encountered this before or have an idea on how to better handle this?

Michael Merickel

unread,
Jun 8, 2022, 8:23:44 PM6/8/22
to pylons-...@googlegroups.com
I doubt you’ll have the same problem with “python -m pyramid.scripts.pserve dev_admin.ini” but would be good to find out. The process list appears to be due to the virtualenv wrapper around a console script which this should skip. 

- Michael

On Jun 8, 2022, at 15:31, 'Jonathan Vanasco' via pylons-discuss <pylons-...@googlegroups.com> wrote:

I doubt anyone here may have experienced this, but I've run out of resources to explore on this...
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/45ca3e17-e8a7-459a-ac69-492b3fadaeccn%40googlegroups.com.

Michael Merickel

unread,
Jun 8, 2022, 8:24:44 PM6/8/22
to pylons-...@googlegroups.com
Well I might have answered too hastily. Seems the first process is controlled by fabric and not virtualenv. 

- Michael

On Jun 8, 2022, at 19:23, Michael Merickel <mmer...@gmail.com> wrote:

I doubt you’ll have the same problem with “python -m pyramid.scripts.pserve dev_admin.ini” but would be good to find out. The process list appears to be due to the virtualenv wrapper around a console script which this should skip. 

Jonathan Vanasco

unread,
Jun 9, 2022, 10:02:00 AM6/9/22
to pylons-discuss
Well, it was worth a shot and is giving me some ideas to try.  (I just tested this myself too, just to be sure it wouldn't work.)
Reply all
Reply to author
Forward
0 new messages