File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 22
33import copy
44import os
5+ import shutil
6+ import tempfile
57import secrets
68from contextlib import AsyncExitStack , asynccontextmanager
79from inspect import signature
@@ -214,6 +216,24 @@ def __init__(
214216 cast ("Tag | TagList" , ui ), lib_prefix = self .lib_prefix
215217 )
216218
219+ def __del__ (self ):
220+ current_temp_dir = os .path .realpath (tempfile .gettempdir ())
221+
222+ user_dependencies = [
223+ v .source ["subdir" ]
224+ for k , v in self ._registered_dependencies .items ()
225+ if k .startswith ("include-" )
226+ ]
227+
228+ for item in user_dependencies :
229+ # Only remove the item if it exists and it is in the current temp directory
230+ if (
231+ os .path .exists (item )
232+ and os .path .commonprefix ([os .path .realpath (item ), current_temp_dir ])
233+ == current_temp_dir
234+ ):
235+ shutil .rmtree (item )
236+
217237 def init_starlette_app (self ) -> starlette .applications .Starlette :
218238 routes : list [starlette .routing .BaseRoute ] = [
219239 starlette .routing .WebSocketRoute ("/websocket/" , self ._on_connect_cb ),
You can’t perform that action at this time.
0 commit comments