Administrator
|
I have the following:
p := PipeableOSProcess command: 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; /usr/local/bin/python3 /path/to/gst-mic.py'. The program doesn't stop until it's "told" to, which from a command line means CTRL-C. However, `p processProxy sigint` [1] doesn't work. I assume because I don't have the actual python process, but rather the shell process. This guess is based on seeing that `p processProxy programName = '/bin/sh'` and arguments are `"#('-c' 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; /usr/local/bin/python3 /Users/sean/Dynabook/Repositories/seandenigris/DynaChef/asr/experiments/continuous/gst-mic.py')"`. Also, if I `ps aux | grep gst-mi` on the command line, I see two processes, and I can effectively send SIGINT to the python process via `kill -SIGINT pid`. Taking a step back, what's the best/easiest/cleanest way for OSP and this little gobject-loop-based Python program to negotiate when it should stop? Thanks! ----- Cheers, Sean -- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Cheers,
Sean |
On Sun, Apr 29, 2018 at 10:23:14PM -0700, Sean P. DeNigris wrote:
> I have the following: > > p := PipeableOSProcess command: 'export > PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; > /usr/local/bin/python3 /path/to/gst-mic.py'. > > The program doesn't stop until it's "told" to, which from a command line > means CTRL-C. However, `p processProxy sigint` [1] doesn't work. I assume > because I don't have the actual python process, but rather the shell > process. This guess is based on seeing that `p processProxy programName = > '/bin/sh'` and arguments are `"#('-c' 'export > PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; > /usr/local/bin/python3 > /Users/sean/Dynabook/Repositories/seandenigris/DynaChef/asr/experiments/continuous/gst-mic.py')"`. > > Also, if I `ps aux | grep gst-mi` on the command line, I see two processes, > and I can effectively send SIGINT to the python process via `kill -SIGINT > pid`. > > Taking a step back, what's the best/easiest/cleanest way for OSP and this > little gobject-loop-based Python program to negotiate when it should stop? > > Thanks! > It looks to me like the Python interpreter has handlers for SIGINT, so I don't know if that would be a good way to terminate it. The SIGTERM signal seems to do the trick though (p processProxy sigterm). I am not very familiar with Python, so I don't know if this will help. But here are two suggestions: 1) In the command line, try putting an 'exec' before the python interpreter, like this: p := PipeableOSProcess command: 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages; exec /usr/local/bin/python3 /path/to/gst-mic.py'. This will cause the python program to directly replace the /bin/sh that started it. From Squeak, it will still look as if your PipeableOSProcess is running a /bin/sh program but actually the /bin/sh will have been replaced by python, and you will therefore be directly connected to the python interpreter with no shell in between. 2) To terminate the python interpreter, try any of these and see if it does what you want: p close. p pipeToInput close. p processProxy sigterm Dave _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Administrator
|
David T. Lewis wrote
> But here are two suggestions… Thanks! I will try. Actually, googling around a bit revealed a similar thread [1] with some great information which I collected into a wiki page [2]. The top two solutions there were: 1. ProxyPipeline (via David T. Lewis). This looks like the first choice for most situations. CommandShell itself uses a ProxyPipeline to represent one or more process proxies from a command line, so you can use that class directly to evaluate a command line: ProxyPipeline command: '/bin/sleep 10' 2. PipeableOSProcess - The Long Way This gives you total control (at the obvious cost of LOC!). env := CommandShell new environment. pwd := '/'. args := Array with: '-jar' with: '/path/with/another space/jenkins.war'. desc := Array with: nil with: nil with: nil. p := PipeableOSProcess new: '/usr/bin/java' arguments: args environment: env descriptors: desc workingDir: pwd errorPipelineStream: nil The thing I find eery is *not* that I ask the same questions over and over, but that it seems to be almost the same day of the year even many years apart! (May 7th, 2012 -> April 29th, 2018) 1. http://forum.world.st/Running-in-background-with-OSProcess-tp4615534.html ----- Cheers, Sean -- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Cheers,
Sean |
On Mon, Apr 30, 2018 at 12:53:30PM -0700, Sean P. DeNigris wrote:
> David T. Lewis wrote > > But here are two suggestions??? > > Thanks! I will try. Actually, googling around a bit revealed a similar > thread [1] with some great information which I collected into a wiki page > [2]. The top two solutions there were: > > 1. ProxyPipeline (via David T. Lewis). This looks like the first choice for > most situations. > > CommandShell itself uses a ProxyPipeline to represent one or more process > proxies from a command line, so you can use that class directly to evaluate > a command line: > > ProxyPipeline command: '/bin/sleep 10' > > 2. PipeableOSProcess - The Long Way > > This gives you total control (at the obvious cost of LOC!). > > env := CommandShell new environment. > pwd := '/'. > args := Array > with: '-jar' > with: '/path/with/another space/jenkins.war'. > desc := Array with: nil with: nil with: nil. > p := PipeableOSProcess > new: '/usr/bin/java' > arguments: args > environment: env > descriptors: desc > workingDir: pwd > errorPipelineStream: nil > > > The thing I find eery is *not* that I ask the same questions over and over, > but that it seems to be almost the same day of the year even many years > apart! (May 7th, 2012 -> April 29th, 2018) > > 1. http://forum.world.st/Running-in-background-with-OSProcess-tp4615534.html > Hi Sean, LOL! I think you and I must both be forgetting the same amount of material every six years, because I didn't remember it either :-) This does point to a need to be able to something like ProxyPipeline or PipeableOSProcess simply and with less confusion, and maybe with a class name that is not so wierd that nobody could ever remember it. Thanks, Dave _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Administrator
|
In reply to this post by Sean P. DeNigris
Sean P. DeNigris wrote
> I collected into a wiki page [2] Oops! Forgot the link: https://github.com/seandenigris/pharo/wiki/OSProcess Feel free to harvest for OSP docs if you see anything worthwhile. I also linked to the threads of some of our more interesting (IMHO) exchanges re OSP over the years… ----- Cheers, Sean -- Sent from: http://forum.world.st/Squeak-Beginners-f107673.html _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Cheers,
Sean |
On Mon, Apr 30, 2018 at 05:18:16PM -0700, Sean P. DeNigris wrote:
> Sean P. DeNigris wrote > > I collected into a wiki page [2] > > Oops! Forgot the link: https://github.com/seandenigris/pharo/wiki/OSProcess > Feel free to harvest for OSP docs if you see anything worthwhile. I also > linked to the threads of some of our more interesting (IMHO) exchanges re > OSP over the years??? > Thank you!!! Dave _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |