Beispiel #1
0
    def main(self):
        conn_up = MyProtocolConnectionStateEvent.createMatcher(
            MyProtocolConnectionStateEvent.UP)
        yield (conn_up, )
        conn = self.event.connection
        requests = [
            conn.protocol.request(
                conn, d.message10_sum_request(numbers=list(range(i, 100 + i))),
                self) for i in range(0, 10000)
        ]

        def subr(k):
            r = []
            for i in range(k, len(requests), 20):
                for m in requests[i]:
                    yield m
                r.append(self.retvalue)
            self.retvalue = r

        start = time()
        for m in self.executeAll([subr(i) for i in range(0, 20)]):
            yield m
        end = time()
        results = [r for r0 in self.retvalue for r in r0[0]]
        print('%d results in %f secs, %d errors' %
              (len(results), end - start,
               len([m for m in results if m.type == d.ERROR])))
        for m in conn.shutdown():
            yield m
Beispiel #2
0
    async def main(self):
        conn_up = MyProtocolConnectionStateEvent.createMatcher(MyProtocolConnectionStateEvent.UP)
        ev = await conn_up
        conn = ev.connection
        requests = [conn.protocol.request(conn, d.message10_sum_request(numbers=list(range(i, 100 + i))), self)
                    for i in range(0, 10000)]

        async def subr(k):
            r = []
            for i in range(k, len(requests), 20):
                r.append(await requests[i])
            return r

        start = time()
        result = await self.execute_all([subr(i) for i in range(0, 20)])
        end = time()
        results = [r for r0 in result
                   for r in r0]
        print('%d results in %f secs, %d errors' % (
            len(results), end - start, len([m for m in results if m.type == d.ERROR])))
        await conn.shutdown()
Beispiel #3
0
 def main(self):
     conn_up = MyProtocolConnectionStateEvent.createMatcher(MyProtocolConnectionStateEvent.UP)
     yield (conn_up,)
     conn = self.event.connection
     requests = [conn.protocol.request(conn, d.message10_sum_request(numbers = list(range(i,100+i))), self)
                               for i in range(0, 10000)]
     def subr(k):
         r = []
         for i in range(k, len(requests), 20):
             for m in requests[i]:
                 yield m
             r.append(self.retvalue)
         self.retvalue = r
     start = time()
     for m in self.executeAll([subr(i) for i in range(0,20)]):
         yield m
     end = time()
     results = [r for r0 in self.retvalue
                for r in r0[0]]
     print('%d results in %f secs, %d errors' % (len(results), end-start, len([m for m in results if m.type == d.ERROR])))
     for m in conn.shutdown():
         yield m
Beispiel #4
0
from __future__ import print_function
import socket
import protocoldef as d
from namedstruct import dump

if __name__ == '__main__':
    s = socket.create_connection(('127.0.0.1', 9723))
    try:
        s.sendall(d.message[0].tobytes([
            d.message10_sum_request(numbers=[1, 2, 3]),
            d.message10_sum_request(numbers=list(range(0, 100))),
            d.message10_sum_request(numbers=[i * i for i in range(0, 100)]),
        ]))
        data = b''
        while True:
            data2 = s.recv(4096)
            if not data2:
                break
            data += data2
            r = d.message[3].parse(data)
            if r:
                messages, _ = r
                break
        print(dump(messages))
    finally:
        s.close()
Beispiel #5
0
from __future__ import print_function
import socket
import protocoldef as d
from namedstruct import dump

if __name__ == '__main__':
    s = socket.create_connection(('127.0.0.1', 9723))
    try:
        s.sendall(d.message[0].tobytes([d.message10_sum_request(numbers = [1,2,3]),
                                        d.message10_sum_request(numbers = list(range(0,100))),
                                        d.message10_sum_request(numbers = [i*i for i in range(0,100)]),]))
        data = b''
        while True:
            data2 = s.recv(4096)
            if not data2:
                break
            data += data2
            r = d.message[3].parse(data)
            if r:
                messages, _ = r
                break
        print(dump(messages))
    finally:
        s.close()