#checkapi.py
import time
def add(a,b):
return a + b
def loop():
while True:
time.sleep(10)
print("loop running")
loop()
#apicheck.py
import checkapi
print(checkapi.add(5, 6))
output
------
apicheck.py showing "loop running"
please check out this. Why this happening.
Q. How to call a running method and get it's return value ?.
import checkapi, theloopfunction starts running, because it saysloop()at the end of that file. Because that function has an infinite loop, nothing else can happen afterward. It's not at all clear what you want to happen instead.if __name__ == "__main__": loop()to guard against this.