示例#1
0
def test_subscribed_client_multiple():
    got = []

    client = Client(server_name='someserver',
                    db_address='inproc://db',
                    sub_address='inproc://pub',
                    push_address='inproc://pull',
                    this_config=True)

    client1 = Client(server_name='someserver',
                     db_address='inproc://db',
                     sub_address='inproc://pub',
                     push_address='inproc://pull',
                     this_config=True)

    with ThreadPoolExecutor(max_workers=2) as executor:
        results = [
            executor.submit(fake_server, messages=4),
            executor.submit(client.job, 'f', [b'1', b'2'], messages=2),
            executor.submit(client1.job, 'f', [b'a', b'b'], messages=2)
        ]

        for future in concurrent.futures.as_completed(results):
            try:
                result = future.result()
                if result:
                    for r in result:
                        got.append(r)

            except Exception as exc:
                print(exc)

    assert len(got) == 4
示例#2
0
文件: launcher.py 项目: cperales/pylm
def main():
    args = parse_arguments()
    client = Client(args.server, args.db)

    for response in client.job('.'.join([args.server, args.function]),
                               repeat(b' a message', 10),
                               messages=10):
        print(response)
示例#3
0
from pylm.clients import Client
from itertools import repeat

client = Client('my_server',
                'tcp://127.0.0.1:5555',
                sub_address='tcp://127.0.0.1:5581')

if __name__ == '__main__':
    for response in client.job(
        ['my_server.foo', 'my_pipeline.foo', 'my_sink.foo'],
            repeat(b'a message', 10),
            messages=10):
        print('Client got: ', response)
示例#4
0
from pylm.clients import Client

client = Client('my_server', 'tcp://127.0.0.1:5555')

if __name__ == '__main__':
    result = client.eval('my_server.foo', b'a message', messages=1)
    print('Client got: ', result)
示例#5
0
文件: client.py 项目: cperales/pylm
from pylm.clients import Client
from itertools import repeat

client = Client('server', 'tcp://127.0.0.1:5559')

if __name__ == '__main__':
    for response in client.job('server.foo',
                               repeat(b'a message', 10),
                               messages=10):
        print(response)
示例#6
0
 def client_job():
     client = Client('master',
                     db_address,
                     session=None)
     return [r for r in client.job('master.something', [b'1'], messages=1)]
示例#7
0
 def boot_client():
     client = Client('master',
                     db_address,
                     session=None)
     return client.push_address, client.sub_address
示例#8
0
from pylm.clients import Client

client = Client('server',
                'tcp://127.0.0.1:5555',
                sub_address='tcp://127.0.0.1:5558')

if __name__ == '__main__':
    result = client.eval(['server.foo', 'hub.foo'], b'a message')
    print('Client got: ', result)
示例#9
0
from pylm.clients import Client
from itertools import repeat

client = Client('server', 'tcp://127.0.0.1:5559')

if __name__ == '__main__':
    client.set(b' cached data ', 'cached')
    print(client.get('cached'))

    for response in client.job('server.foo',
                               repeat(b'a message', 10),
                               messages=30):
        print(response)
示例#10
0
from pylm.clients import Client
import sys
import json
import codecs
import logging
import csv
import multiprocessing

client = Client(server_name='matlab_pylm',
                db_address='tcp://127.0.0.1:5559',
                logging_level=logging.DEBUG)


def json_generator(json_filename):
    client.logger.info('JSON file name: {}'.format(json_filename))
    with open(json_filename, 'rb') as f:
        reader = codecs.getreader("utf-8")
        json_loaded = json.load(reader(f))
        count = 0
        for j in json_loaded:
            count += 1
            client.logger.debug('JSON number {}'.format(count))
            client.logger.debug('JSON to send: {}'.format(j))
            yield json.dumps(j).encode('utf-8')


def json_list_generator(json_filename):
    client.logger.info('JSON file name: {}'.format(json_filename))
    with open(json_filename, 'rb') as f:
        reader = codecs.getreader("utf-8")
        json_loaded = json.load(reader(f))
示例#11
0
文件: client.py 项目: cperales/pylm
from pylm.clients import Client

client = Client('my_server',
                'tcp://127.0.0.1:5555',
                sub_address='tcp://127.0.0.1:5561')

if __name__ == '__main__':
    result = client.eval(['my_server.foo', 'my_pipeline.foo'], b'a message')
    print('Client got: ', result)