New event loop integration system
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
No repository file or test is identified in the issue. Start by reading the proposed start_guest_run entry point and the host-loop callback examples for asyncio, tkinter, and Qt; clarify which integration API and supported event loops are in scope before implementation. Done would mean an agreed design and working guest-mode integration.
Written by the indexing model from the issue text.
Description
I would like to change our event-loop integration with Trio's guest mode. Trio's guest mode also works on asyncio thanks to aioguest. For it to work, we just need to have a function that can schedule a callback in the host event-loop in a thread-safe way.
- in asyncio, that would be
loop.call_soon_threadsafe(callback), - in tkinter, that would be
tk.after(0, callback). - Qt supports Trio's guest mode, see here.
- ...
For instance, here is how it looks like when the host event-loop is tkinter's:
from tkinter import Tk
from anyio import sleep
from anyioutils import start_guest_run
def run_sync_soon_threadsafe(fn):
tk.after(0, fn)
def done_callback(outcome):
print("done")
async def foo():
for i in range(10):
await sleep(0.1)
print(i)
tk = Tk()
start_guest_run(foo, run_sync_soon_threadsafe=run_sync_soon_threadsafe, done_callback=done_callback)
tk.mainloop()
Before calling tk.mainloop(), we call start_guest_run() which runs foo as a task in tkinter's event-loop.
Thoughts?
- Dominant language
- Python
- Stars
- 734
- Forks
- 411
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ipython/ipykernel
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
ipython/ipykernel#1550 · 1 comment · 1 reaction · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
All issues in ipython/ipykernel
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·