question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EventEmitter loop in napari dock widget

See original GitHub issue

Describe the bug

RuntimeError: EventEmitter loop detected! occurs, although events should be blocked (as far as I understand).

ERROR:root:Unhandled exception:
Traceback (most recent call last):
  File "/home/uwe/research/stardist/napari/magicgui/magicgui/widgets/_bases/value_widget.py", line 44, in <lambda>
    lambda *x: self.changed(value=x[0] if x else None)
  File "/home/uwe/research/stardist/napari/magicgui/magicgui/events.py", line 576, in __call__
    raise RuntimeError("EventEmitter loop detected!")
RuntimeError: EventEmitter loop detected!

To Reproduce

Code for simple napari dock widget (bug is triggered when entering lowercase characters for param):

from napari_plugin_engine import napari_hook_implementation
from magicgui import magic_factory

def to_upper(event):
    val = str(event.value)
    if val != val.upper():
        with event.source.changed.blocker():
            event.source.value = val.upper()

def widget_init(widget):
    widget.param.changed.connect(to_upper)

@magic_factory(widget_init=widget_init)
def widget(param: str):
    pass

@napari_hook_implementation
def napari_experimental_provide_dock_widget():
    return widget

Expected behavior No RuntimeError: EventEmitter loop detected!.

Environment (please complete the following information):

  • OS: Ubuntu 20.04 LTS
  • magicgui version 0.2.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
uschmidt83commented, Mar 19, 2021

FYI, it also happens with @magicgui and a wrapper function:

def widget_wrapper():
    @magicgui
    def widget(param: str):
        pass
    ...
    return widget

@napari_hook_implementation
def napari_experimental_provide_dock_widget():
    return widget_wrapper
0reactions
tlambert03commented, Apr 6, 2021

Strange, the bug happens via both Python and IPython in my plugin.

as long as I can reproduce somewhere, I can probably fix it in both If I remember correctly, it had something to do with the order of connecting events… (though that shouldn’t matter).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting the Event Loop - napari
Start a Qt event loop in which to run the application. napari.run(*[, force, gui_exceptions, ...]) Start the Qt Event Loop ...
Read more >
Error when returning named shapes/surface layer multiple ...
Running a dock widget multiple times (i.e. pressing the call_button ) will cause an error with named shapes (and also surface , not...
Read more >
Event emitter for deleting data within a layer (points, shapes ...
I have tried using viewer.active_layer.events.data.connect(my_callback) (similar to what is mentioned here An Introduction to the Event Loop in ...
Read more >
napari: a multi-dimensional image viewer for Python - Zenodo
To specify a plugin in a Python script: import napari viewer = napari. ... </li> <li>Allow resizing left dock widgets (#4368)&lt ...
Read more >
Turning napari GUI into plugins (Part 4) - GitHub Pages
Putting your GUI into the template. Now we will modify the code to add our widgets. In Github Desktop, let's create a separate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found