forked from Team-DDev/bitsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_blockhandler.py
More file actions
37 lines (27 loc) · 803 Bytes
/
main_blockhandler.py
File metadata and controls
37 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import argparse
import zmq
FLAGS = _ = None
DEBUG = False
def message_receiver():
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.setsockopt_string(zmq.SUBSCRIBE, "")
socket.bind("tcp://*:5556")
while True:
message = socket.recv_json()
print("Received message : ", message)
def main():
if DEBUG:
print(f'Parsed arguments {FLAGS}')
print(f'Unparsed arguments {_}')
try:
message_receiver()
except KeyboardInterrupt:
print("keyboradinterrupt")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--debug', action='store_true',
help='The present debug message')
FLAGS, _ = parser.parse_known_args()
DEBUG = FLAGS.debug
main()