Skip to content

How to detect which frontends are connected #11920

Open

Description

@hmaarrfk

Is there a way to detect which frontends are currently connected to a kernel?

This would be useful for graphical libraries which are trying to decide which backends to utilize automatically for visualization:

vispy/vispy#1708

Thanks!

Activity

  1. tacaswell commented on Oct 20, 2019

    @tacaswell
    Contributor

    It is impossible to tell by design. It is possible for more than one front end to connect which makes any automatic configuration based on that problematic.

  2. hmaarrfk commented on Oct 20, 2019

    @hmaarrfk
    Author

    Hmmm. Is it possible to tell which frontend is running the current lines of code?

  3. tacaswell commented on Oct 23, 2019

    @tacaswell
    Contributor

    I think the protocol is carefully designed to make sure you can not tell. I have gone down this road with Matplotlib and concluded it was not possible (and mostly agree with the design).

  4. hmaarrfk commented on Oct 23, 2019

    @hmaarrfk
    Author

    So how does matplotlib detect which backwnd to use? Could other libraries use the same detection mechanism? Qt vs Web vs tk???

  5. ccordoba12 commented on Oct 23, 2019

    @ccordoba12
    Member

    So how does matplotlib detect which backwnd to use?

    I think it doesn't. It's up to the frontend to try to use the Matplotlib backend set by the user.

    For example, if you set %matplotlib notebook then interactive plots will be rendered as expected inside the notebook, but nothing will be shown in Spyder (and no error will be generated) because qtconsole can't handle Javascript content.

    This limitation will be overcome in our side once we add a new pane in Spyder capable of rendering any web content that comes from the kernel. This is our top priority for Spyder 5, to be released next year.

  6. tacaswell commented on Oct 24, 2019

    @tacaswell
    Contributor

    The only 'auto' thing we do is try to detect if there is a running GUI event loop and we use that one (which is something that is fully on the kernel side of things, see https://github.com/matplotlib/matplotlib/blob/349e2e9e8a33c5a45d2935aae86561bdea10e55b/lib/matplotlib/cbook/__init__.py#L39-L76 ).

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