| 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 | |