From 21d97c32f87902c987f5f02efcbe6397ce1ade77 Mon Sep 17 00:00:00 2001 From: MrYsLab Date: Mon, 9 Dec 2019 10:23:00 -0500 Subject: [PATCH] Accommodate Python 3.8 asyncio changes for Windows --- python_banyan/banyan_base_aio/banyan_base_aio.py | 10 ++++++---- python_banyan/gateway_base_aio/gateway_base_aio.py | 11 ++++++----- setup.py | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/python_banyan/banyan_base_aio/banyan_base_aio.py b/python_banyan/banyan_base_aio/banyan_base_aio.py index 7fdb75a..72a664e 100644 --- a/python_banyan/banyan_base_aio/banyan_base_aio.py +++ b/python_banyan/banyan_base_aio/banyan_base_aio.py @@ -24,6 +24,7 @@ import asyncio import msgpack import msgpack_numpy as m +import sys import zmq import psutil @@ -51,8 +52,8 @@ class BanyanBaseAIO(object): def __init__(self, back_plane_ip_address=None, subscriber_port='43125', publisher_port='43124', process_name='None', numpy=False, external_message_processor=None, receive_loop_idle_addition=None, - connect_time=0.3, subscriber_list=None, event_loop=None, - auto_begin=False): + connect_time=0.3, subscriber_list=None, event_loop=None): + """ The __init__ method sets up all the ZeroMQ "plumbing" @@ -97,6 +98,9 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125', if event_loop: self.event_loop = event_loop else: + # fix for "not implemented" bugs in Python 3.8 + if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) self.event_loop = asyncio.get_event_loop() # if using numpy apply the msgpack_numpy monkey patch @@ -145,8 +149,6 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125', print('Publisher Port = ' + self.publisher_port) print('************************************************************') - # self.event_loop.run_until_complete(self.begin()) - # noinspection PyUnresolvedReferences async def begin(self): # establish the zeromq sub and pub sockets and connect to the backplane diff --git a/python_banyan/gateway_base_aio/gateway_base_aio.py b/python_banyan/gateway_base_aio/gateway_base_aio.py index bd3d3be..7380792 100644 --- a/python_banyan/gateway_base_aio/gateway_base_aio.py +++ b/python_banyan/gateway_base_aio/gateway_base_aio.py @@ -21,6 +21,7 @@ """ import asyncio +import sys from python_banyan.banyan_base_aio import BanyanBaseAIO @@ -70,10 +71,13 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125', if board_type: self.board_type = board_type - # set up the event loop if event_loop: self.event_loop = event_loop + + # fix for "not implemented" bugs in Python 3.8 else: + if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) self.event_loop = asyncio.get_event_loop() if subscriber_list: @@ -155,12 +159,9 @@ async def incoming_message_processing(self, topic, payload): try: command = payload['command'] except KeyError: - print(payload) + print('incoming_message_processed KeyErrer', payload) raise - # pin = None - # tag = '' - # if a tag is provided and the tag is in the dictionary, fetch # the associated pin number if 'tag' in payload: diff --git a/setup.py b/setup.py index dd91058..b2717c3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='python-banyan', - version='3.7', + version='3.8', packages=[ 'python_banyan', 'python_banyan.banyan_base',