check if server is running under windows to fix issue with mqtt under win and python 3.9

This commit is contained in:
avollkopf 2022-03-04 16:36:50 +01:00
parent a16c14feca
commit db4e75525f
2 changed files with 8 additions and 1 deletions

View file

@ -1 +1 @@
__version__ = "4.0.2.0.a11"
__version__ = "4.0.2.0.a12"

View file

@ -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__