mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-18 10:44:33 +08:00
Reduce CPU usage of dev mode (#7113)
* Add code * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
82fe73d042
commit
28e8a8a3ec
5
.changeset/petite-islands-follow.md
Normal file
5
.changeset/petite-islands-follow.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Reduce CPU usage of dev mode
|
@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
import site
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
@ -63,9 +64,14 @@ def _setup_config(
|
||||
|
||||
watching_dirs = []
|
||||
if str(gradio_folder).strip():
|
||||
watching_dirs.append(gradio_folder)
|
||||
message += f" '{gradio_folder}'"
|
||||
message_change_count += 1
|
||||
package_install = any(
|
||||
utils.is_in_or_equal(gradio_folder, d) for d in site.getsitepackages()
|
||||
)
|
||||
if not package_install:
|
||||
# This is a source install
|
||||
watching_dirs.append(gradio_folder)
|
||||
message += f" '{gradio_folder}'"
|
||||
message_change_count += 1
|
||||
|
||||
abs_parent = abs_original_path.parent
|
||||
if str(abs_parent).strip():
|
||||
|
@ -14,6 +14,7 @@ import os
|
||||
import pkgutil
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
import typing
|
||||
import urllib.parse
|
||||
@ -223,6 +224,7 @@ def watchfn(reloader: SourceFileReloader):
|
||||
else:
|
||||
reloader.swap_blocks(demo)
|
||||
mtimes = {}
|
||||
time.sleep(0.05)
|
||||
|
||||
|
||||
def colab_check() -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user