Commit 63750e48 authored by Anael Beutot's avatar Anael Beutot Committed by Antoine Millet
Browse files

Added a decorator for plugins to perform work in pyev thread

parent fc44ac06
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
from functools import wraps


def main_thread(func):
    """Decorator for plugin methods that need to be executed in pyev thread.

    Actually anything that has an attribute `main` that points to an instance of
    MainLoop.
    """
    @wraps(func)
    def decorated(self, *args, **kwargs):
        return self.main.call_in_main_thread(func, self, *args, **kwargs)

    return decorated