Skip to content

how to integrate custom event loop in ipykernel 7.x #1490

Description

@ugogon

Issue:
As explained here, I wrote a custom GUI integration using do_one_iteration that worked in the past. Version 7 breaks this without providing an alternative in the documentation. How can I integrate a custom event loop in the latest version? What are the best practices?

Activity

ianthomas23 commented on Jan 13, 2026

@ianthomas23
Collaborator

There is some discussion in #1458, get_shell_stream(self.kernel).flush(limit=1) is probably what you are looking for.

ugogon commented on Jan 13, 2026

@ugogon
Author

Thanks for the quick reply. Unfortunately that does not seem to work.

Where do I have to call it/what is self?

My integration is currently pretty basic:

@ipykernel.eventloops.register_integration('mygui')
def loop_mygui(kernel):
    last = time.time()

    def poll():
        nonlocal last
        now = time.time()
        if now-last > kernel._poll_interval:
            last = now
            loop = asyncio.get_event_loop()
            loop.run_until_complete(kernel.do_one_iteration())

    while True:
        [...] # my gui stuff
        poll()

Can you point me in the right direction? I do not get what the kernel needs to do to process the incoming messages as I currently do not get the whole ipykernel data flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions