Title: Asyncio Python API - Request For Comment · Issue #3 · codehz/bun_python · GitHub
Open Graph Title: Asyncio Python API - Request For Comment · Issue #3 · codehz/bun_python
X Title: Asyncio Python API - Request For Comment · Issue #3 · codehz/bun_python
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...
Open Graph 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 { s...
X 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' c...
Opengraph URL: https://github.com/codehz/bun_python/issues/3
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Asyncio Python API - Request For Comment","articleBody":"Would like to add `asyncio` support to bun_python.\r\n\r\nBefore I submit the PR, would like to get some thoughts on which API is preferable:\r\n\r\n### Option A:\r\n\r\n```typescript\r\nimport { python, asyncio } from 'bun_python'\r\n\r\nconst {\r\n say_hello,\r\n} = python.runModule(await Bun.file(path.resolve(import.meta.dir, 'example.py')).text(), 'example.py')\r\n\r\npython.run_loop() // returns a promise that resolves when the loop stops\r\n\r\nawait asyncio(say_hello('world'), timeout_ms)\r\n\r\nmain().finally(() =\u003e python.stop_loop())\r\n```\r\n\r\nOption A has an `asyncio()` function to wrap Py Coroutines or Py `asyncio.Task` into an awaitable JS Promise.\r\n\r\n### Option B:\r\n\r\n```typescript\r\nimport { python } from 'bun_python'\r\n\r\nconst {\r\n say_hello,\r\n} = python.runModule(await Bun.file(path.resolve(import.meta.dir, 'example.py')).text(), 'example.py')\r\n\r\npython.run_loop() // returns a promise that resolves when the loop stops\r\n\r\nawait say_hello('world')\r\n\r\nmain().finally(() =\u003e python.stop_loop())\r\n```\r\n\r\nOption B adds a `then()` method to all PyObject proxy to make them awaitable.\r\n\r\n@codehz ","author":{"url":"https://github.com/heri16","@type":"Person","name":"heri16"},"datePublished":"2024-05-04T07:51:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/3/bun_python/issues/3"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6b9ae000-4e2b-cc8a-1b75-2e9b20035523 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B24C:684B7:1FD113D:28B8D3E:6975E029 |
| html-safe-nonce | 2d0e8a33bd483aa69858100307c6961e31136bfd016d5c9d1f84a490e6a9c2e1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjRDOjY4NEI3OjFGRDExM0Q6MjhCOEQzRTo2OTc1RTAyOSIsInZpc2l0b3JfaWQiOiIyNzUwNjA5MDI3OTI1MTM5NDk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3987180d5150eeab04cb259394bf160fb89b01f671dbe4e02ac65af41f1b95db |
| hovercard-subject-tag | issue:2278823156 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/codehz/bun_python/3/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78d2f136ef23da5e387fed6b4b8ba293cd938e7486393d70d2d84145cd38b25a/codehz/bun_python/issues/3 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78d2f136ef23da5e387fed6b4b8ba293cd938e7486393d70d2d84145cd38b25a/codehz/bun_python/issues/3 |
| og:image:alt | 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 { s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | heri16 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2bce766e7450b03e00b2fc5badd417927ce33a860e78cda3e4ecb9bbd1374cc6 |
| turbo-cache-control | no-preview |
| go-import | github.com/codehz/bun_python git https://github.com/codehz/bun_python.git |
| octolytics-dimension-user_id | 13158903 |
| octolytics-dimension-user_login | codehz |
| octolytics-dimension-repository_id | 681174080 |
| octolytics-dimension-repository_nwo | codehz/bun_python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 681174080 |
| octolytics-dimension-repository_network_root_nwo | codehz/bun_python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fcca2b8ef702b5f7f91427a6e920fa44446fe312 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width