From db4e75525fd8e9d2614c67f91df89faa9a758d2d Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Fri, 4 Mar 2022 16:36:50 +0100 Subject: [PATCH] check if server is running under windows to fix issue with mqtt under win and python 3.9 --- cbpi/__init__.py | 2 +- cbpi/craftbeerpi.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 4ac905a..2903a50 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.2.0.a11" +__version__ = "4.0.2.0.a12" diff --git a/cbpi/craftbeerpi.py b/cbpi/craftbeerpi.py index fbbde3f..10dee52 100644 --- a/cbpi/craftbeerpi.py +++ b/cbpi/craftbeerpi.py @@ -1,5 +1,7 @@ import asyncio +import sys +from asyncio import set_event_loop_policy, WindowsSelectorEventLoopPolicy import json from voluptuous.schema_builder import message from cbpi.api.dataclasses import NotificationType @@ -82,6 +84,11 @@ async def error_middleware(request, handler): class CraftBeerPi: def __init__(self): + + operationsystem= sys.platform + if operationsystem.startswith('win'): + set_event_loop_policy(WindowsSelectorEventLoopPolicy()) + self.path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1]) # The path to the package dir self.version = __version__