@@ -150,9 +150,13 @@ def execute_request(request):
150150 # exec mirrors deployed-mode module import: the code is the
151151 # user's full module, so __name__ is set like an import would
152152 # (main guards stay inert) and decorated handles resolve to
153- # their wrapped functions
154- namespace = {"__name__" : "__runpod_live__" }
155- exec (function_code , namespace ) # noqa: S102 - that is the job
153+ # their wrapped functions. the source is written to a real
154+ # file first so inspect.getsource works inside the function
155+ # (nested .remote() calls re-extract sibling source)
156+ source_path = _materialize_source (function_code )
157+ namespace = {"__name__" : "__runpod_live__" , "__file__" : source_path }
158+ code_obj = compile (function_code , source_path , "exec" )
159+ exec (code_obj , namespace ) # noqa: S102 - that is the job
156160 if function_name not in namespace :
157161 return {
158162 "success" : False ,
@@ -188,6 +192,21 @@ def execute_request(request):
188192 }
189193
190194
195+ def _materialize_source (function_code ):
196+ """persist request source to a stable path for inspect/linecache."""
197+ import hashlib
198+ import tempfile
199+
200+ digest = hashlib .sha256 (function_code .encode ()).hexdigest ()[:16 ]
201+ path = os .path .join (
202+ tempfile .gettempdir (), f"runpod_live_{ digest } .py"
203+ )
204+ if not os .path .exists (path ):
205+ with open (path , "w" ) as f :
206+ f .write (function_code )
207+ return path
208+
209+
191210class _Tee (io .TextIOBase ):
192211 """write-through to multiple streams, flushing eagerly so log
193212 followers see lines as they happen."""
0 commit comments