The correct solution to these problems is to document the requirements
of your function from the callers, and let the callers deal with that
according to their needs. (I suspect that in the case that bothers
you, you yourself are that caller, which makes it easier to implement
such protocols.)
Btw, you never explained why you are bothered specifically by
while-no-input. Nor did you describe the problem.
I'm writing a completion-at-point-function and completion table. This
table internally uses asynchronous subprocesses to get completions.
This completion-at-point-function and table may be called by the popular
completion frontend corfu-mode. corfu-mode uses while-no-input around
calls to completion tables.
I want to ensure that my asynchronous subprocesses are deleted even if
my code is interrupted by corfu's while-no-input.
I can't change the protocol of completion tables or
completion-at-point-functions (that's defined by Emacs), and I'm not the
one calling while-no-input (that's corfu-mode).