PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
17.63k stars 1.65k forks source link

ipdb breakpoints in async functions hang indefinitely after upgrading to Prefect 3 #15843

Open etsvetanov opened 1 month ago

etsvetanov commented 1 month ago

Bug summary

Using import ipdb; ipdb.set_trace() in a async function hangs indefinitely when prefect imports are present. Using pdb does not result in the same behaviour.

Tested in a docker container python:3.12.2

from prefect import flow, get_run_logger, task
import asyncio

async def fn():
    print('fn() start')
    import ipdb

    ipdb.set_trace()
    print('fn() end')

if __name__ == "__main__":
    asyncio.run(fn())

Running the above script with python script.py will hang indefinitely (after printing fn() start). Removing prefect imports fixes the issue. Normal def functions do not seem affected.

The installed packages are:

anyio==4.6.2.post1
ipdb==0.13.13
ipython==8.29.0
prefect==3.0.11
pytest==8.3.3
pytest-asyncio==0.24.0

Version info

Version:             3.0.11
API version:         0.8.4
Python version:      3.12.2
Git commit:          a17ccfcf
Built:               Thu, Oct 24, 2024 5:36 PM
OS/Arch:             linux/aarch64
Profile:             ephemeral
Server type:         ephemeral
Pydantic version:    2.9.2
Server:
  Database:          sqlite
  SQLite version:    3.40.1

Additional context

No response

teocns commented 15 hours ago

Disable printing/logging and if running with pytest use -s addopts