From 8c78d469e29b54d6ab5c085e6246348050f46009 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 27 Sep 2012 22:18:39 +0200 Subject: [PATCH] Use Pykka proxies to send events With Pykka >= 0.16, sending events can be done using proxies instead of manually crafting Pykka's internal function call messages. --- docs/changes.rst | 4 +++- docs/installation/index.rst | 2 +- mopidy/core/listener.py | 14 ++++---------- requirements/core.txt | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index caec53ba..17d50072 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -8,7 +8,9 @@ This change log is used to track all major changes to Mopidy. v0.9.0 (in development) ======================= -- Nothing so far. +**Dependencies** + +- Pykka >= 0.16 is now required. v0.8.0 (2012-09-20) diff --git a/docs/installation/index.rst b/docs/installation/index.rst index 66b920f8..d5728c00 100644 --- a/docs/installation/index.rst +++ b/docs/installation/index.rst @@ -26,7 +26,7 @@ dependencies installed. - Python >= 2.6, < 3 - - Pykka >= 0.12.3:: + - Pykka >= 0.16:: sudo pip install -U pykka diff --git a/mopidy/core/listener.py b/mopidy/core/listener.py index a77b29a8..9476ac4f 100644 --- a/mopidy/core/listener.py +++ b/mopidy/core/listener.py @@ -1,4 +1,4 @@ -from pykka import registry +from pykka.registry import ActorRegistry class CoreListener(object): @@ -15,14 +15,9 @@ class CoreListener(object): @staticmethod def send(event, **kwargs): """Helper to allow calling of core listener events""" - # FIXME this should be updated once Pykka supports non-blocking calls - # on proxies or some similar solution. - registry.ActorRegistry.broadcast({ - 'command': 'pykka_call', - 'attr_path': (event,), - 'args': [], - 'kwargs': kwargs, - }, target_class=CoreListener) + listeners = ActorRegistry.get_by_class(CoreListener) + for listener in listeners: + getattr(listener.proxy(), event)(**kwargs) def track_playback_paused(self, track, time_position): """ @@ -50,7 +45,6 @@ class CoreListener(object): """ pass - def track_playback_started(self, track): """ Called whenever a new track starts playing. diff --git a/requirements/core.txt b/requirements/core.txt index 8f9da622..1c2371f3 100644 --- a/requirements/core.txt +++ b/requirements/core.txt @@ -1 +1 @@ -Pykka >= 0.12.3 +Pykka >= 0.16