Skip to content

Commit 21d97c3

Browse files
MrYsLabMrYsLab
authored andcommitted
Accommodate Python 3.8 asyncio changes for Windows
1 parent f27ced6 commit 21d97c3

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

python_banyan/banyan_base_aio/banyan_base_aio.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import asyncio
2525
import msgpack
2626
import msgpack_numpy as m
27+
import sys
2728
import zmq
2829
import psutil
2930

@@ -51,8 +52,8 @@ class BanyanBaseAIO(object):
5152
def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
5253
publisher_port='43124', process_name='None', numpy=False,
5354
external_message_processor=None, receive_loop_idle_addition=None,
54-
connect_time=0.3, subscriber_list=None, event_loop=None,
55-
auto_begin=False):
55+
connect_time=0.3, subscriber_list=None, event_loop=None):
56+
5657
"""
5758
The __init__ method sets up all the ZeroMQ "plumbing"
5859
@@ -97,6 +98,9 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
9798
if event_loop:
9899
self.event_loop = event_loop
99100
else:
101+
# fix for "not implemented" bugs in Python 3.8
102+
if sys.platform == 'win32':
103+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
100104
self.event_loop = asyncio.get_event_loop()
101105

102106
# if using numpy apply the msgpack_numpy monkey patch
@@ -145,8 +149,6 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
145149
print('Publisher Port = ' + self.publisher_port)
146150
print('************************************************************')
147151

148-
# self.event_loop.run_until_complete(self.begin())
149-
150152
# noinspection PyUnresolvedReferences
151153
async def begin(self):
152154
# establish the zeromq sub and pub sockets and connect to the backplane

python_banyan/gateway_base_aio/gateway_base_aio.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"""
2222

2323
import asyncio
24+
import sys
2425
from python_banyan.banyan_base_aio import BanyanBaseAIO
2526

2627

@@ -70,10 +71,13 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
7071
if board_type:
7172
self.board_type = board_type
7273

73-
# set up the event loop
7474
if event_loop:
7575
self.event_loop = event_loop
76+
77+
# fix for "not implemented" bugs in Python 3.8
7678
else:
79+
if sys.platform == 'win32':
80+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
7781
self.event_loop = asyncio.get_event_loop()
7882

7983
if subscriber_list:
@@ -155,12 +159,9 @@ async def incoming_message_processing(self, topic, payload):
155159
try:
156160
command = payload['command']
157161
except KeyError:
158-
print(payload)
162+
print('incoming_message_processed KeyErrer', payload)
159163
raise
160164

161-
# pin = None
162-
# tag = ''
163-
164165
# if a tag is provided and the tag is in the dictionary, fetch
165166
# the associated pin number
166167
if 'tag' in payload:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='python-banyan',
8-
version='3.7',
8+
version='3.8',
99
packages=[
1010
'python_banyan',
1111
'python_banyan.banyan_base',

0 commit comments

Comments
 (0)