LearningEveryday
LearningEveryday

Reputation: 217

Check if a function is running in Python 2.7

If I have these two fuctions:

def func1():
    print "I am function1"

def func2():
    print "Function 1 is still running."

while(func1 is running):
    func2()

How do I check if function 1 is still running?

Upvotes: 1

Views: 8873

Answers (1)

LearningEveryday
LearningEveryday

Reputation: 217

I solved this using the threading module. Below is my code.

import threading
from threading import Thread

func1_thread = Thread(target = func1)

while func1_thread.isAlive():
    func2()

Upvotes: 2

Related Questions