-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Currently integrations are usually based on external scripts that "import some value from the entry module" and use that for some blocking serving, like
> mcp-hmr script.py:appand
> uvicorn-hmr main:appBut there exist cases like promplate/hmr#42 where frameworks encourage people to invoke the blocking main loop inside the entry file.
Integrating every framework is too annoying. But forcing downstream users to learn how to use HMR_CONTEXT.effect is also not polite.
The point is, if the entry module blocks, we will never have a chance to start the reload process or even call the on_dispose hook because the ReactiveModule.__load is still running!
I’m wondering if we could add an API like on_dispose -- maybe called mark_block or mark_as_main_loop, which works like
def mark_as_main_loop[T: Callable](func: T) -> T:
@wraps(func) # maybe we need to mark it as an async function through `inspect` if it is
def wrapper(*args, **kwargs):
__stop_tracking()
__start_the_reloader_daemon() # we may need to warn users if they didn't set an `on_dispose` hook here
return func(*args, **kwargs)Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested