1
from multiprocessing import *
from time import *
def a():
    while(1):
        None

b=Process(target=a)
b.start()
sleep(15)
print b.is_alive()

b.is_alive() always prints false,

could someone help me to know how to start this process'

Update : i was running the code from python IDLE , opening file in IDLE and pressing f5 ,and the code was always throwing false

but when i try to run the code from cmd > python.exe file.py , the code works fine

PDHide
  • 18,113
  • 2
  • 31
  • 46
  • 1
    Works fine for me. Confirm that `a()` is starting and/or ending by adding some debug statements. – mhawke Jul 09 '17 at 10:24
  • Add a `__main__` entry point and add a `sleep` into the`while` Loop. – stovfl Jul 09 '17 at 17:48
  • @mhawke i added debug statement , the function a() doesn't starts at all, it starts only if i explicitly call b.run() – PDHide Jul 10 '17 at 04:31
  • @stovfl i added if __name__ == '__main__': , and added a print "hello" before while(1) , it seems a() is not at all starting – PDHide Jul 10 '17 at 04:33
  • Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) this the version i use – PDHide Jul 10 '17 at 04:39
  • Hi thank you everyone for the reply , i have an update , i was running the code from IDLE , (opening in IDLE and pressing F5) and the code was not working , but when i try from cmd python.exe file.py , the code works fine – PDHide Jul 10 '17 at 04:44
  • Possible duplicate of [Can multiprocessing Process class be run from IDLE](https://stackoverflow.com/questions/35293178/can-multiprocessing-process-class-be-run-from-idle) – stovfl Jul 10 '17 at 05:46
  • Thanks everyone for the help – PDHide Jul 11 '17 at 17:24

0 Answers0