Spaces:
Sleeping
Sleeping
File size: 652 Bytes
1089f07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import os
import importlib
import gradio as gr
def greet(name):
parent_name = get_process_name()
return f"Hello {name}!! a greeting from {parent_name}"
def get_process_name():
if importlib.util.find_spec("psutil"):
import psutil
parent_pid = os.getppid()
try:
parent_name = str(psutil.Process(parent_pid).name())
return parent_name
except psutil.NoSuchProcess: # Catch the error caused by the process no longer existing
print("NoSuchProcess")
return "Uknown Process"
if __name__ == "__main__":
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |