Spaces:
Runtime error
Runtime error
Download gra.py from CodeCrew/discord_bot: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/CodeCrew/discord_bot/resolve/main/gra.py
- Command line
-
hf download hf://spaces/CodeCrew/discord_bot/gra.py
-
curl -L -o gra.py https://huggingface.co/spaces/CodeCrew/discord_bot/resolve/main/gra.py
1.03 kB
| from fastapi import FastAPI | |
| import gradio as gr | |
| import asyncio, time | |
| import psutil | |
| import os | |
| from threading import Thread | |
| app = FastAPI() | |
| def change_textbox(): | |
| return gr.Textbox.update(visible=True) | |
| def read_main(): | |
| for exec_num in range(0, 1): | |
| X = [i for i in range(0, 9000000)] | |
| memory_usage_dict = dict(psutil.virtual_memory()._asdict()) | |
| memory_usage_percent = memory_usage_dict['percent'] | |
| # current process RAM usage | |
| pid = os.getpid() | |
| current_process = psutil.Process(pid) | |
| current_process_memory_usage_as_KB = current_process.memory_info()[0] / 2.**20 | |
| del X | |
| return { "0" : { "메모리" : f"{memory_usage_percent}%", "mykb" : f"{current_process_memory_usage_as_KB: 9.3f} KB" } } | |
| def run(): | |
| with gr.Blocks() as demo: | |
| gr.Markdown("Start") | |
| gr.mount_gradio_app(app, demo, path="/memory") | |
| demo.launch() | |
| def keep_alive(): | |
| server = Thread(target=run) | |
| server.start() |