Skip to content

multiprocessing after a prefect test hangs #19112

@atombear

Description

@atombear

Bug summary

on linux, though not on darwin, the following example hangs with pytest file.py

contents of file.py

import prefect
from prefect.testing.utilities import prefect_test_harness
from multiprocessing import Process

def thread_func():
    print("HI")
    return 10

@prefect.task
def task():
    return 1

@prefect.flow
def flow():
    return task.submit()

def test():
    with prefect_test_harness():
        flow()

    p = Process(target=thread_func)
    p.start()
    print("ENDING")
    p.join()

Version info

Version:              3.4.22
API version:          0.8.4
Python version:       3.11.13
Git commit:           6a6d114f
Built:                Fri, Oct 3, 2025 06:15 PM
OS/Arch:              linux/x86_64
Profile:              default
Server type:          server
Pydantic version:     2.11.10
Server:
  Database:           postgresql
  PostgreSQL version: 14.17

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions