File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
22import os
33import sys
4+ import gc
45import tempfile
56from importlib .resources import files
67
@@ -178,6 +179,7 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
178179 "nodes" : nodes ,
179180 }
180181
182+ engine = None
181183 try :
182184 # 4. Initialize and Run Engine
183185 engine = Engine (config , operators )
@@ -214,6 +216,10 @@ def run_graphgen(params: WebuiParams, progress=gr.Progress()):
214216 raise gr .Error (f"Error occurred: { str (e )} " )
215217
216218 finally :
219+ if engine :
220+ del engine
221+ gc .collect ()
222+
217223 # Clean up workspace
218224 cleanup_workspace (working_dir ) # Optional: keep for debugging or enable
219225
Original file line number Diff line number Diff line change 1- import os
2- import shutil
1+ import time
32import uuid
3+ import shutil
4+ import os
5+ import stat
46
57
68def setup_workspace (folder ):
@@ -17,6 +19,15 @@ def setup_workspace(folder):
1719 return log_file , working_dir
1820
1921
20- def cleanup_workspace (folder ):
21- if os .path .exists (folder ):
22- shutil .rmtree (folder )
22+ def on_rm_error (func , path , exc_info ):
23+ os .chmod (path , stat .S_IWRITE )
24+
25+ time .sleep (0.5 )
26+ try :
27+ func (path )
28+ except Exception :
29+ pass
30+
31+ def cleanup_workspace (working_dir ):
32+ if os .path .exists (working_dir ):
33+ shutil .rmtree (working_dir , onerror = on_rm_error )
You can’t perform that action at this time.
0 commit comments