abc.py
:
import xyz
#also import other required modules
#other required code
xyz.func()
#other required code
xyz.py
:
import threading
import sys
#few threads
def func():
#start all threads
threads.start()
threads.join(timeout)
#if not joined within given time, terminate all threads and exit from xyz.py
if (threads.isAlive()):
sys.exit()
#I used sys.exit() but it is not working for me.What else can I do here? `
I have a python script abc.py that imports another python script xyz.py. I am using sys.exit() function in xyz.py. Problem I am facing here is when sys.exit() function is executed in xyz.py file, my main file i.e. abc.py also gets terminated. I don't want this to happen. My file abc.py should remain ON even though xyz.py file terminates. Is there any way to achieve this? I will be grateful to receive any help/guidance.I am using python 2.6.6 on centos 6.5.
Aucun commentaire:
Enregistrer un commentaire