Update monkey_patch_gradio.py
This commit is contained in:
parent
00186f76f4
commit
b069bb1f2e
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import importlib
|
import importlib
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
file_path = pathlib.Path(importlib.util.find_spec("gradio").submodule_search_locations[0]) / "strings.py"
|
file_path = pathlib.Path(importlib.util.find_spec("gradio").submodule_search_locations[0]) / "strings.py"
|
||||||
|
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
|
@ -9,5 +10,9 @@ with open(file_path, 'r') as f:
|
||||||
new_contents = contents.replace('threading.Thread(target=get_updated_messaging, args=(en,)).start()', '')
|
new_contents = contents.replace('threading.Thread(target=get_updated_messaging, args=(en,)).start()', '')
|
||||||
if contents != new_contents:
|
if contents != new_contents:
|
||||||
print('Patching gradio to prevent it from calling home every time it gets imported...')
|
print('Patching gradio to prevent it from calling home every time it gets imported...')
|
||||||
with open(file_path, 'w') as f:
|
try:
|
||||||
f.write(new_contents)
|
# This is dirty but harmless.
|
||||||
|
with open(file_path, 'w') as f:
|
||||||
|
f.write(new_contents)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue