From 52223e3ad81d9ac0559fbb16b421eed8b5aa437f Mon Sep 17 00:00:00 2001 From: andrei Date: Tue, 24 Oct 2017 17:56:43 -0700 Subject: [PATCH] [holster] update Emitter instances to use `spawn_each` --- disco/client.py | 4 ++-- disco/util/websocket.py | 3 +-- disco/voice/client.py | 4 ++-- disco/voice/player.py | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/disco/client.py b/disco/client.py index a407ab2..9e0c30e 100644 --- a/disco/client.py +++ b/disco/client.py @@ -88,8 +88,8 @@ class Client(LoggingClass): super(Client, self).__init__() self.config = config - self.events = Emitter(gevent.spawn) - self.packets = Emitter(gevent.spawn) + self.events = Emitter(spawn_each=True) + self.packets = Emitter(spawn_each=True) self.api = APIClient(self.config.token, self) self.gw = GatewayClient(self, self.config.max_reconnects, self.config.encoder) diff --git a/disco/util/websocket.py b/disco/util/websocket.py index 3871b13..bd684e2 100644 --- a/disco/util/websocket.py +++ b/disco/util/websocket.py @@ -1,7 +1,6 @@ from __future__ import absolute_import import websocket -import gevent import six from holster.emitter import Emitter @@ -21,7 +20,7 @@ class Websocket(LoggingClass, websocket.WebSocketApp): LoggingClass.__init__(self) websocket.WebSocketApp.__init__(self, *args, **kwargs) - self.emitter = Emitter(gevent.spawn) + self.emitter = Emitter(spawn_each=True) # Hack to get events to emit for var in six.iterkeys(self.__dict__): diff --git a/disco/voice/client.py b/disco/voice/client.py index af480df..35b68f8 100644 --- a/disco/voice/client.py +++ b/disco/voice/client.py @@ -129,13 +129,13 @@ class VoiceClient(LoggingClass): self.encoder = encoder or JSONEncoder # 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.SESSION_DESCRIPTION, self.on_voice_sdp) # State + state change emitter self.state = VoiceState.DISCONNECTED - self.state_emitter = Emitter(gevent.spawn) + self.state_emitter = Emitter(spawn_each=True) # Connection metadata self.token = None diff --git a/disco/voice/player.py b/disco/voice/player.py index e09e28a..7fa6ee0 100644 --- a/disco/voice/player.py +++ b/disco/voice/player.py @@ -44,7 +44,7 @@ class Player(object): self.complete = gevent.event.Event() # Event emitter for metadata - self.events = Emitter(gevent.spawn) + self.events = Emitter(spawn_each=True) def disconnect(self): self.client.disconnect()