<commit_before>#!/usr/bin/python
import sys
import zmq

# Connection to our subscriber socket
contextS = zmq.Context()
subscriber = contextS.socket(zmq.SUB)

subscriber.setsockopt(zmq.SUBSCRIBE, "")
poller = zmq.Poller()
poller.register(subscriber, zmq.POLLIN)

# Connection to our publisher socket
contextP = zmq.Context()
publisher = contextP.socket(zmq.PUB)
publisher.connect("tcp://192.168.1.120:5579")
publisher.sndhwm = 1100000


class publisher_and_subscriber():
    def userChoice(self, userChoice):
        if userChoice==1:
            subscriber.connect('tcp://192.168.1.120:5580')
        if userChoice==2:
            subscriber.connect('tcp://172.16.31.10:5560')

    def subscriber(self):
        socks = dict(poller.poll(0))
        if socks:
            if socks.get(subscriber) == zmq.POLLIN:
                string = subscriber.recv(zmq.NOBLOCK)
                return string

            else:
                print "error:message timeout"

    def publisher(self, var1):
		publisher.send_string('{}'.format(var1),zmq.NOBLOCK)
<commit_msg>Update SocketCommunication.py<commit_after>#!/usr/bin/python
import sys
import zmq

# Connection to our subscriber socket
contextS = zmq.Context()
subscriber = contextS.socket(zmq.SUB)

subscriber.setsockopt(zmq.SUBSCRIBE, "")
poller = zmq.Poller()
poller.register(subscriber, zmq.POLLIN)

# Connection to our publisher socket
contextP = zmq.Context()
publisher = contextP.socket(zmq.PUB)
publisher.connect("tcp://localhost:5579")
publisher.sndhwm = 1100000


class publisher_and_subscriber():
    def userChoice(self, userChoice):
        if userChoice==1:
            subscriber.connect('tcp://localhost:5580')
        if userChoice==2:
            subscriber.connect('tcp://172.16.31.10:5560')

    def subscriber(self):
        socks = dict(poller.poll(0))
        if socks:
            if socks.get(subscriber) == zmq.POLLIN:
                string = subscriber.recv(zmq.NOBLOCK)
                return string

            else:
                print "error:message timeout"

    def publisher(self, var1):
		publisher.send_string('{}'.format(var1),zmq.NOBLOCK)

{'fraction_non_alphanumeric': 0.12652869238005646, 'fraction_numerical': 0.04045155221072436, 'mean_word_length': 3.0207939508506616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '118017', 'n_tokens_mistral': 750, 'n_tokens_neox': 682, 'n_words': 127}