Remove useless Task creation

pull/8/head
Nicolas Jouanin 2015-09-02 22:41:24 +02:00
rodzic fb6c2784bb
commit 313c4a367a
1 zmienionych plików z 14 dodań i 18 usunięć

Wyświetl plik

@ -166,41 +166,37 @@ class ProtocolHandler:
EVENT_MQTT_PACKET_RECEIVED, packet=packet, session=self.session)
self._loop.call_soon(self.on_packet_received.send, packet)
task = None
if packet.fixed_header.packet_type == CONNACK:
task = asyncio.Task(self.handle_connack(packet), loop=self._loop)
yield from self.handle_connack(packet)
elif packet.fixed_header.packet_type == SUBSCRIBE:
task = asyncio.Task(self.handle_subscribe(packet), loop=self._loop)
yield from self.handle_subscribe(packet)
elif packet.fixed_header.packet_type == UNSUBSCRIBE:
task = asyncio.Task(self.handle_unsubscribe(packet), loop=self._loop)
yield from self.handle_unsubscribe(packet)
elif packet.fixed_header.packet_type == SUBACK:
task = asyncio.Task(self.handle_suback(packet), loop=self._loop)
yield from self.handle_suback(packet)
elif packet.fixed_header.packet_type == UNSUBACK:
task = asyncio.Task(self.handle_unsuback(packet), loop=self._loop)
yield from self.handle_unsuback(packet)
elif packet.fixed_header.packet_type == PUBACK:
task = asyncio.Task(self.handle_puback(packet), loop=self._loop)
yield from self.handle_puback(packet)
elif packet.fixed_header.packet_type == PUBREC:
task = asyncio.Task(self.handle_pubrec(packet), loop=self._loop)
yield from self.handle_pubrec(packet)
elif packet.fixed_header.packet_type == PUBREL:
task = asyncio.Task(self.handle_pubrel(packet), loop=self._loop)
yield from self.handle_pubrel(packet)
elif packet.fixed_header.packet_type == PUBCOMP:
task = asyncio.Task(self.handle_pubcomp(packet), loop=self._loop)
yield from self.handle_pubcomp(packet)
elif packet.fixed_header.packet_type == PINGREQ:
task = asyncio.Task(self.handle_pingreq(packet), loop=self._loop)
yield from self.handle_pingreq(packet)
elif packet.fixed_header.packet_type == PINGRESP:
task = asyncio.Task(self.handle_pingresp(packet), loop=self._loop)
yield from self.handle_pingresp(packet)
elif packet.fixed_header.packet_type == PUBLISH:
task = asyncio.Task(self.handle_publish(packet), loop=self._loop)
yield from self.handle_publish(packet)
elif packet.fixed_header.packet_type == DISCONNECT:
task = asyncio.Task(self.handle_disconnect(packet), loop=self._loop)
yield from self.handle_disconnect(packet)
elif packet.fixed_header.packet_type == CONNECT:
task = asyncio.Task(self.handle_connect(packet), loop=self._loop)
self.handle_connect(packet)
else:
self.logger.warn("%s Unhandled packet type: %s" %
(self.session.client_id, packet.fixed_header.packet_type))
if task:
# Wait for message handling ends
yield from asyncio.wait([task], loop=self._loop)
else:
self.logger.debug("%s No more data (EOF received), stopping reader coro" % self.session.client_id)
yield from self.handle_connection_closed()