From b911d463151a1d8ff67bb74ffb0e057f8f712063 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Dec 2018 11:37:18 +0100 Subject: [PATCH] Create a new event loop in the Pushbullet backend --- platypush/backend/pushbullet/__init__.py | 5 ++--- platypush/context/__init__.py | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platypush/backend/pushbullet/__init__.py b/platypush/backend/pushbullet/__init__.py index ff0b696b1..561117d13 100644 --- a/platypush/backend/pushbullet/__init__.py +++ b/platypush/backend/pushbullet/__init__.py @@ -5,7 +5,7 @@ import time import websockets from platypush.config import Config -from platypush.context import get_or_create_event_loop +from platypush.context import create_event_loop from platypush.message import Message from platypush.message.event.pushbullet import PushbulletEvent @@ -98,7 +98,6 @@ class PushbulletBackend(Backend): return is_duplicate def on_push(self, ws, data): - print('***** {}'.format(data)) try: # Parse the push try: @@ -152,8 +151,8 @@ class PushbulletBackend(Backend): self.on_push(self.ws, push) self.close() - loop = get_or_create_event_loop() + loop = create_event_loop() loop.run_until_complete(pushbullet_client()) loop.run_forever() diff --git a/platypush/context/__init__.py b/platypush/context/__init__.py index 6b46449fe..8971ad388 100644 --- a/platypush/context/__init__.py +++ b/platypush/context/__init__.py @@ -114,6 +114,11 @@ def register_plugin(name, plugin, **kwargs): """ Registers a plugin instance by name """ global plugins +def create_event_loop(): + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + return loop + def get_or_create_event_loop(): try: loop = asyncio.get_event_loop()