Skip to content

Commit 468db65

Browse files
committed
Renamed self.context to self.my_context for multiple inheritance applications
1 parent 21d97c3 commit 468db65

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

examples/ecs/ecs/tk_echo_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ def get_message(self):
172172
self.root.destroy()
173173
self.publisher.close()
174174
self.subscriber.close()
175-
self.context.term()
175+
self.my_context.term()
176176
sys.exit(0)
177177
except KeyboardInterrupt:
178178
self.root.destroy()
179179
self.publisher.close()
180180
self.subscriber.close()
181-
self.context.term()
181+
self.my_context.term()
182182
sys.exit(0)
183183

184184
def incoming_message_processing(self, topic, payload):

examples/tk_echo_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import tkFont as font
3434
import ttk
3535

36-
import umsgpack
36+
import msgpack
3737
import zmq
3838
from python_banyan.banyan_base import BanyanBase
3939

@@ -158,7 +158,7 @@ def get_message(self):
158158
"""
159159
try:
160160
data = self.subscriber.recv_multipart(zmq.NOBLOCK)
161-
self.incoming_message_processing(data[0].decode(), umsgpack.unpackb(data[1]))
161+
self.incoming_message_processing(data[0].decode(), msgpack.unpackb(data[1]))
162162
time.sleep(.001)
163163
self.root.after(1, self.get_message)
164164

@@ -171,13 +171,13 @@ def get_message(self):
171171
self.root.destroy()
172172
self.publisher.close()
173173
self.subscriber.close()
174-
self.context.term()
174+
self.my_context.term()
175175
sys.exit(0)
176176
except KeyboardInterrupt:
177177
self.root.destroy()
178178
self.publisher.close()
179179
self.subscriber.close()
180-
self.context.term()
180+
self.my_context.term()
181181
sys.exit(0)
182182

183183
def incoming_message_processing(self, topic, payload):

python_banyan/banyan_base/banyan_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
145145
print('************************************************************')
146146

147147
# establish the zeromq sub and pub sockets and connect to the backplane
148-
self.context = zmq.Context()
149-
self.subscriber = self.context.socket(zmq.SUB)
148+
self.my_context = zmq.Context()
149+
self.subscriber = self.my_context.socket(zmq.SUB)
150150
connect_string = "tcp://" + self.back_plane_ip_address + ':' + self.subscriber_port
151151
self.subscriber.connect(connect_string)
152152

153-
self.publisher = self.context.socket(zmq.PUB)
153+
self.publisher = self.my_context.socket(zmq.PUB)
154154
connect_string = "tcp://" + self.back_plane_ip_address + ':' + self.publisher_port
155155
self.publisher.connect(connect_string)
156156

@@ -251,7 +251,7 @@ def clean_up(self):
251251
"""
252252
self.publisher.close()
253253
self.subscriber.close()
254-
self.context.term()
254+
self.my_context.term()
255255

256256
# When creating a derived component, replicate the code below and replace
257257
# banyan_base with a name of your choice.

python_banyan/banyan_base_aio/banyan_base_aio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
9090
self.receive_loop_idle_addition = receive_loop_idle_addition
9191
self.connect_time = connect_time
9292
self.subscriber_list = subscriber_list
93-
self.context = None
93+
self.my_context = None
9494
self.subscriber = None
9595
self.publisher = None
9696
self.the_task = None
@@ -152,14 +152,14 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
152152
# noinspection PyUnresolvedReferences
153153
async def begin(self):
154154
# establish the zeromq sub and pub sockets and connect to the backplane
155-
if not self.context:
156-
self.context = zmq.asyncio.Context()
155+
if not self.my_context:
156+
self.my_context = zmq.asyncio.Context()
157157
# noinspection PyUnresolvedReferences
158-
self.subscriber = self.context.socket(zmq.SUB)
158+
self.subscriber = self.my_context.socket(zmq.SUB)
159159
connect_string = "tcp://" + self.back_plane_ip_address + ':' + self.subscriber_port
160160
self.subscriber.connect(connect_string)
161161

162-
self.publisher = self.context.socket(zmq.PUB)
162+
self.publisher = self.my_context.socket(zmq.PUB)
163163
connect_string = "tcp://" + self.back_plane_ip_address + ':' + self.publisher_port
164164
self.publisher.connect(connect_string)
165165

@@ -275,4 +275,4 @@ async def clean_up(self):
275275
"""
276276
await self.publisher.close()
277277
await self.subscriber.close()
278-
await self.context.term()
278+
await self.my_context.term()

python_banyan/banyan_base_multi/banyan_base_multi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, back_plane_csv_file=None, process_name='None',
107107
self.loop_time = loop_time
108108

109109
# get a zeromq context
110-
self.context = zmq.Context()
110+
self.my_context = zmq.Context()
111111

112112
# a list of dictionaries describing connections to the back planes
113113
self.backplane_table = []
@@ -128,13 +128,13 @@ def __init__(self, back_plane_csv_file=None, process_name='None',
128128
# setup a publisher and subscriber for each backplane
129129
subscriber = None
130130
if row['subscriber_port']:
131-
subscriber = self.context.socket(zmq.SUB)
131+
subscriber = self.my_context.socket(zmq.SUB)
132132
connect_string = "tcp://" + row['ip_address'] + ':' + row['subscriber_port']
133133
subscriber.connect(connect_string)
134134

135135
publisher = None
136136
if row['publisher_port']:
137-
publisher = self.context.socket(zmq.PUB)
137+
publisher = self.my_context.socket(zmq.PUB)
138138
connect_string = "tcp://" + row['ip_address'] + ':' + row['publisher_port']
139139
publisher.connect(connect_string)
140140

@@ -337,7 +337,7 @@ def clean_up(self):
337337
element['publisher'].close()
338338
if element['subscriber']:
339339
element['subscriber'].close()
340-
self.context.term()
340+
self.my_context.term()
341341

342342
# When creating a derived component, replicate the code below and replace banyan_base_multi with a name of your choice
343343

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.8',
8+
version='3.9',
99
packages=[
1010
'python_banyan',
1111
'python_banyan.banyan_base',

0 commit comments

Comments
 (0)