1

I am looking something like this.
If i have a method in a class, now that i accept 2 command line arguments (start, stop), so when i run python script.py start, it will start automatically, now after sometime if user enters script.py stop it should end gracefully, can it be done.

This is what i have tried to do

from multiprocessing import Process, Queue
from time import sleep
import sys

def start(name):
    print('hello', name)
    print "Sleeping for 60 sec"
    # sleep (60)



if __name__ == '__main__':


p = Process(target=start, args=('bob',))
p.start()

Thanks

xor
  • 2,668
  • 2
  • 28
  • 42
Vinay D
  • 273
  • 2
  • 4
  • 11
  • This looks similar, is this what you want? http://stackoverflow.com/questions/17856928/how-to-terminate-process-from-python-using-pid – M4rtini Dec 08 '13 at 22:34

0 Answers0