MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / run_in_process

Function run_in_process

test/aaa_profiling/test_memusage.py:225–247  ·  view source on GitHub ↗
(*func_args)

Source from the content-addressed store, hash-verified

223 # return run_plain
224
225 def run_in_process(*func_args):
226 # see
227 # https://docs.python.org/3.14/whatsnew/3.14.html
228 # #incompatible-changes - the default run type is no longer
229 # "fork", but since we are running closures in the process
230 # we need forked mode
231 ctx = multiprocessing.get_context("fork")
232 queue = ctx.Queue()
233 proc = ctx.Process(target=profile, args=(queue, func_args))
234 proc.start()
235 while True:
236 row = queue.get()
237 typ = row[0]
238 if typ == "samples":
239 print("sample gc sizes:", row[1])
240 elif typ == "status":
241 print(row[1])
242 elif typ == "result":
243 break
244 else:
245 assert False, "can't parse row"
246 proc.join()
247 assert row[1], row[2]
248
249 return run_in_process
250

Callers

nothing calls this directly

Calls 3

getMethod · 0.95
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected