Ticket #5562: pb_bugs_client.py

File pb_bugs_client.py, 860 bytes (added by dynamicgl, 2 years ago)
Line 
1#coding=utf-8
2from twisted.internet import iocpreactor
3iocpreactor.install()
4from twisted.internet import reactor,defer
5from twisted.spread import pb
6import time,cPickle
7
8
9def main():
10    @defer.inlineCallbacks
11    def call():
12        factory = pb.PBClientFactory()
13        reactor.connectTCP("localhost",12345,factory)
14        remoteD = yield factory.getRootObject()
15        for i in range(5):
16            begin = time.time()
17            val = {"hello":"hello"*100,"foo":"bar","baz":100,u"these are bytes":(1,2,3)}
18            defers2 = [remoteD.callRemote("bad", cPickle.dumps(val, 2)) for i in range(1000)]
19            for d in defers2:
20                yield d
21            end = time.time()
22            print end-begin
23        reactor.stop()
24    reactor.callLater(0,call)
25    reactor.run()
26
27if __name__ == "__main__":
28    main()