Skip to content

Commit

Permalink
Accommodate Python 3.8 asyncio changes for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MrYsLab authored and MrYsLab committed Dec 9, 2019
1 parent f27ced6 commit 21d97c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions python_banyan/banyan_base_aio/banyan_base_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import asyncio
import msgpack
import msgpack_numpy as m
import sys
import zmq
import psutil

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions python_banyan/gateway_base_aio/gateway_base_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

import asyncio
import sys
from python_banyan.banyan_base_aio import BanyanBaseAIO


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='python-banyan',
version='3.7',
version='3.8',
packages=[
'python_banyan',
'python_banyan.banyan_base',
Expand Down

0 comments on commit 21d97c3

Please sign in to comment.