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.
This commit is contained in:
parent
e7f08a7a20
commit
8c78d469e2
@ -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)
|
||||
|
||||
@ -26,7 +26,7 @@ dependencies installed.
|
||||
|
||||
- Python >= 2.6, < 3
|
||||
|
||||
- Pykka >= 0.12.3::
|
||||
- Pykka >= 0.16::
|
||||
|
||||
sudo pip install -U pykka
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -1 +1 @@
|
||||
Pykka >= 0.12.3
|
||||
Pykka >= 0.16
|
||||
|
||||
Loading…
Reference in New Issue
Block a user