Browse Source

[holster] update Emitter instances to use `spawn_each`

pull/60/head
andrei 8 years ago
parent
commit
52223e3ad8
  1. 4
      disco/client.py
  2. 3
      disco/util/websocket.py
  3. 4
      disco/voice/client.py
  4. 2
      disco/voice/player.py

4
disco/client.py

@ -88,8 +88,8 @@ class Client(LoggingClass):
super(Client, self).__init__() super(Client, self).__init__()
self.config = config self.config = config
self.events = Emitter(gevent.spawn) self.events = Emitter(spawn_each=True)
self.packets = Emitter(gevent.spawn) self.packets = Emitter(spawn_each=True)
self.api = APIClient(self.config.token, self) self.api = APIClient(self.config.token, self)
self.gw = GatewayClient(self, self.config.max_reconnects, self.config.encoder) self.gw = GatewayClient(self, self.config.max_reconnects, self.config.encoder)

3
disco/util/websocket.py

@ -1,7 +1,6 @@
from __future__ import absolute_import from __future__ import absolute_import
import websocket import websocket
import gevent
import six import six
from holster.emitter import Emitter from holster.emitter import Emitter
@ -21,7 +20,7 @@ class Websocket(LoggingClass, websocket.WebSocketApp):
LoggingClass.__init__(self) LoggingClass.__init__(self)
websocket.WebSocketApp.__init__(self, *args, **kwargs) websocket.WebSocketApp.__init__(self, *args, **kwargs)
self.emitter = Emitter(gevent.spawn) self.emitter = Emitter(spawn_each=True)
# Hack to get events to emit # Hack to get events to emit
for var in six.iterkeys(self.__dict__): for var in six.iterkeys(self.__dict__):

4
disco/voice/client.py

@ -129,13 +129,13 @@ class VoiceClient(LoggingClass):
self.encoder = encoder or JSONEncoder self.encoder = encoder or JSONEncoder
# Bind to some WS packets # Bind to some WS packets
self.packets = Emitter(gevent.spawn) self.packets = Emitter(spawn_each=True)
self.packets.on(VoiceOPCode.READY, self.on_voice_ready) self.packets.on(VoiceOPCode.READY, self.on_voice_ready)
self.packets.on(VoiceOPCode.SESSION_DESCRIPTION, self.on_voice_sdp) self.packets.on(VoiceOPCode.SESSION_DESCRIPTION, self.on_voice_sdp)
# State + state change emitter # State + state change emitter
self.state = VoiceState.DISCONNECTED self.state = VoiceState.DISCONNECTED
self.state_emitter = Emitter(gevent.spawn) self.state_emitter = Emitter(spawn_each=True)
# Connection metadata # Connection metadata
self.token = None self.token = None

2
disco/voice/player.py

@ -44,7 +44,7 @@ class Player(object):
self.complete = gevent.event.Event() self.complete = gevent.event.Event()
# Event emitter for metadata # Event emitter for metadata
self.events = Emitter(gevent.spawn) self.events = Emitter(spawn_each=True)
def disconnect(self): def disconnect(self):
self.client.disconnect() self.client.disconnect()

Loading…
Cancel
Save