Spaces:
Sleeping
Sleeping
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() |