Without this PR,
```js
let f = pyodide.globals.get("some_async_function");
setTimeout(f, 100);
```
doesn't work because `setTimeout` calls `f` which returns a coroutine which is left unscheduled and so the actual work in `f` is never executed. This is surprising to people, see for instance https://github.com/pyodide/pyodide/discussions/2229. This changes the behavior to automatically schedule all coroutines created from async functions called from Javascript so that async functions can be used as Javascript event handlers.
ENH Automatically schedule coroutines. Without this PR,
```js
let f = pyodide.globals.get("some_async_function");
setTimeout(f, 100);
```
doesn't work because `setTimeout` calls `f` which returns a coroutine which is left unscheduled and so the actual work in `f` is never executed. This is surprising to people, see for instance https://github.com/pyodide/pyodide/discussions/2229. This changes the behavior to automatically schedule all coroutines created from async functions called from Javascript so that async functions can be used as Javascript event handlers.
from pyodide_build.testing import run_in_pyodide


@run_in_pyodide(packages=["cffi"])
def test_cffi_asprintf():
    from cffi import FFI

    ffi = FFI()
    ffi.cdef(
        """int asprintf(char** buf, const char *format, ...);   // copy-pasted from the man page"""
    )
    C = ffi.dlopen(None)  # loads the entire C namespace
    buf = ffi.new("char**")
    arg1 = ffi.new("char[]", b"wo")
    arg2 = ffi.new("char[]", b"ld")
    C.asprintf(buf, b"hello %sr%s", arg1, arg2)
    assert ffi.string(buf[0]).decode() == "hello world"

from pyodide_build.testing import run_in_pyodide


@run_in_pyodide(packages=["cffi"])
def test_cffi_asprintf():
    from cffi import FFI

    ffi = FFI()
    ffi.cdef(
        """int asprintf(char** buf, const char *format, ...);   // copy-pasted from the man page"""
    )
    C = ffi.dlopen(None)  # loads the entire C namespace
    buf = ffi.new("char**")
    arg1 = ffi.new("char[]", b"wo")
    arg2 = ffi.new("char[]", b"ld")
    C.asprintf(buf, b"hello %sr%s", arg1, arg2)
    assert ffi.string(buf[0]).decode() == "hello world"
