Skip to content

Commit

Permalink
Renamed self.context to self.my_context for multiple inheritance appl…
Browse files Browse the repository at this point in the history
…ications
  • Loading branch information
MrYsLab committed Jan 18, 2020
1 parent 21d97c3 commit 468db65
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions examples/ecs/ecs/tk_echo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ def get_message(self):
self.root.destroy()
self.publisher.close()
self.subscriber.close()
self.context.term()
self.my_context.term()
sys.exit(0)
except KeyboardInterrupt:
self.root.destroy()
self.publisher.close()
self.subscriber.close()
self.context.term()
self.my_context.term()
sys.exit(0)

def incoming_message_processing(self, topic, payload):
Expand Down
8 changes: 4 additions & 4 deletions examples/tk_echo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import tkFont as font
import ttk

import umsgpack
import msgpack
import zmq
from python_banyan.banyan_base import BanyanBase

Expand Down Expand Up @@ -158,7 +158,7 @@ def get_message(self):
"""
try:
data = self.subscriber.recv_multipart(zmq.NOBLOCK)
self.incoming_message_processing(data[0].decode(), umsgpack.unpackb(data[1]))
self.incoming_message_processing(data[0].decode(), msgpack.unpackb(data[1]))
time.sleep(.001)
self.root.after(1, self.get_message)

Expand All @@ -171,13 +171,13 @@ def get_message(self):
self.root.destroy()
self.publisher.close()
self.subscriber.close()
self.context.term()
self.my_context.term()
sys.exit(0)
except KeyboardInterrupt:
self.root.destroy()
self.publisher.close()
self.subscriber.close()
self.context.term()
self.my_context.term()
sys.exit(0)

def incoming_message_processing(self, topic, payload):
Expand Down
8 changes: 4 additions & 4 deletions python_banyan/banyan_base/banyan_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
print('************************************************************')

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

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

Expand Down Expand Up @@ -251,7 +251,7 @@ def clean_up(self):
"""
self.publisher.close()
self.subscriber.close()
self.context.term()
self.my_context.term()

# When creating a derived component, replicate the code below and replace
# banyan_base with a name of your choice.
Expand Down
12 changes: 6 additions & 6 deletions python_banyan/banyan_base_aio/banyan_base_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
self.receive_loop_idle_addition = receive_loop_idle_addition
self.connect_time = connect_time
self.subscriber_list = subscriber_list
self.context = None
self.my_context = None
self.subscriber = None
self.publisher = None
self.the_task = None
Expand Down Expand Up @@ -152,14 +152,14 @@ def __init__(self, back_plane_ip_address=None, subscriber_port='43125',
# noinspection PyUnresolvedReferences
async def begin(self):
# establish the zeromq sub and pub sockets and connect to the backplane
if not self.context:
self.context = zmq.asyncio.Context()
if not self.my_context:
self.my_context = zmq.asyncio.Context()
# noinspection PyUnresolvedReferences
self.subscriber = self.context.socket(zmq.SUB)
self.subscriber = self.my_context.socket(zmq.SUB)
connect_string = "tcp://" + self.back_plane_ip_address + ':' + self.subscriber_port
self.subscriber.connect(connect_string)

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

Expand Down Expand Up @@ -275,4 +275,4 @@ async def clean_up(self):
"""
await self.publisher.close()
await self.subscriber.close()
await self.context.term()
await self.my_context.term()
8 changes: 4 additions & 4 deletions python_banyan/banyan_base_multi/banyan_base_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, back_plane_csv_file=None, process_name='None',
self.loop_time = loop_time

# get a zeromq context
self.context = zmq.Context()
self.my_context = zmq.Context()

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

publisher = None
if row['publisher_port']:
publisher = self.context.socket(zmq.PUB)
publisher = self.my_context.socket(zmq.PUB)
connect_string = "tcp://" + row['ip_address'] + ':' + row['publisher_port']
publisher.connect(connect_string)

Expand Down Expand Up @@ -337,7 +337,7 @@ def clean_up(self):
element['publisher'].close()
if element['subscriber']:
element['subscriber'].close()
self.context.term()
self.my_context.term()

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

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.8',
version='3.9',
packages=[
'python_banyan',
'python_banyan.banyan_base',
Expand Down

0 comments on commit 468db65

Please sign in to comment.