From b069bb1f2e43ab5783ab09dcedcc9a32dd3d473b Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:32:42 -0300 Subject: [PATCH] Update monkey_patch_gradio.py --- modules/monkey_patch_gradio.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/monkey_patch_gradio.py b/modules/monkey_patch_gradio.py index dcfc64e8..83e4a5d9 100644 --- a/modules/monkey_patch_gradio.py +++ b/modules/monkey_patch_gradio.py @@ -1,6 +1,7 @@ import importlib import pathlib + file_path = pathlib.Path(importlib.util.find_spec("gradio").submodule_search_locations[0]) / "strings.py" 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()', '') if contents != new_contents: print('Patching gradio to prevent it from calling home every time it gets imported...') - with open(file_path, 'w') as f: - f.write(new_contents) + try: + # This is dirty but harmless. + with open(file_path, 'w') as f: + f.write(new_contents) + except: + pass