Open
Description
Would like to add asyncio
support to bun_python.
Before I submit the PR, would like to get some thoughts on which API is preferable:
Option A:
import { python, asyncio } from 'bun_python'
const {
say_hello,
} = python.runModule(await Bun.file(path.resolve(import.meta.dir, 'example.py')).text(), 'example.py')
python.run_loop() // returns a promise that resolves when the loop stops
await asyncio(say_hello('world'), timeout_ms)
main().finally(() => python.stop_loop())
Option A has an asyncio()
function to wrap Py Coroutines or Py asyncio.Task
into an awaitable JS Promise.
Option B:
import { python } from 'bun_python'
const {
say_hello,
} = python.runModule(await Bun.file(path.resolve(import.meta.dir, 'example.py')).text(), 'example.py')
python.run_loop() // returns a promise that resolves when the loop stops
await say_hello('world')
main().finally(() => python.stop_loop())
Option B adds a then()
method to all PyObject proxy to make them awaitable.
Metadata
Metadata
Assignees
Labels
No labels