예제 #1
0
파일: mdh.py 프로젝트: gotcha/maitredhotel
def publish(addr, who, url):
    writer = MalamuteClient()
    print_and_flush("connect")
    writer.connect(addr, 100, who)
    print_and_flush("set_producer")
    writer.set_producer(PRODUCER)

    while True:
        now = datetime.datetime.now()
        writer.send(url, [b'success', str(now).encode(UTF8)])
        time.sleep(10)
예제 #2
0
파일: mdh.py 프로젝트: gotcha/maitredhotel
def publish(addr, who, url):
    writer = MalamuteClient()
    print_and_flush("connect")
    writer.connect(addr, 100, who)
    print_and_flush("set_producer")
    writer.set_producer(PRODUCER)

    while True:
        now = datetime.datetime.now()
        writer.send(url, [b'success', str(now).encode(UTF8)])
        time.sleep(10)
예제 #3
0
파일: mdh.py 프로젝트: gotcha/maitredhotel
def commit(addr, who, filename, repository):
    os.chdir(repository)
    reader = MalamuteClient()
    print_and_flush("connect")
    reader.connect(addr, 100, who)
    print_and_flush("set_consumer")
    reader.set_consumer(PRODUCER, b'')

    while True:
        _, who, url, messages = reader.recv()
        url = url.decode(UTF8)
        messages = [msg.decode(UTF8) for msg in messages]
        write_and_commit(filename, url, messages)
예제 #4
0
파일: mdh.py 프로젝트: gotcha/maitredhotel
def commit(addr, who, filename, repository):
    os.chdir(repository)
    reader = MalamuteClient()
    print_and_flush("connect")
    reader.connect(addr, 100, who)
    print_and_flush("set_consumer")
    reader.set_consumer(PRODUCER, b'')

    while True:
        _, who, url, messages = reader.recv()
        url = url.decode(UTF8)
        messages = [msg.decode(UTF8) for msg in messages]
        write_and_commit(filename, url, messages)
예제 #5
0
def test(addr):
    service = MalamuteClient()
    service.connect(addr, 100, b'service')
    service.set_worker(b'service', b'derps')

    writer = MalamuteClient()
    print("writer.connect")
    writer.connect(addr, 100, b'writer')
    print("writer.set_producer")
    writer.set_producer(b'writer')

    reader = MalamuteClient()
    print("reader.connect")
    reader.connect(addr, 100, b'reader')
    print("reader.set_consumer")
    reader.set_consumer(b'writer', b'foo')
    reader.set_consumer(b'writer', b'bar')

    print("writer.send")
    writer.send(b'foo', [b'whoaaa', b'whaaaaaa'])
    writer.send(b'bar', [b'whoaaa', b'whaaaaaa'])
    print(reader.recv())
    print(reader.recv())

    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
    print(service.recv())
    print(service.recv())
    print(service.recv())

    service.sendto(b'reader', b'response', None, 100, [b'ok'])
    print(reader.recv())
예제 #6
0
def test(addr):
	service = MalamuteClient()
	service.connect(addr, 100, b'service')
	service.set_worker(b'service', b'derps')

	writer = MalamuteClient()
	print("writer.connect")
	writer.connect(addr, 100, b'writer')
	print("writer.set_producer")
	writer.set_producer(b'writer')

	reader = MalamuteClient()
	print("reader.connect")
	reader.connect(addr, 100, b'reader')
	print("reader.set_consumer")
	reader.set_consumer(b'writer', b'foo')
	reader.set_consumer(b'writer', b'bar')

	print("writer.send")
	writer.send(b'foo', [b'whoaaa', b'whaaaaaa'])
	writer.send(b'bar', [b'whoaaa', b'whaaaaaa'])
	print(reader.recv())
	print(reader.recv())

	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	reader.sendfor(b'service', b'derps', None, 100, [b'foooooo'])
	print(service.recv())
	print(service.recv())
	print(service.recv())

	service.sendto(b'reader', b'response', None, 100, [b'ok'])
	print(reader.recv())