Exemple #1
0
from pyzbus import BusClient

client = BusClient(host='127.0.0.1', port=15555)

print client.publish('MyPubSub', '', 'topic1', ['frame1', 'from Python'])

client.destroy()
Exemple #2
0
from pyzbus import BusClient

client = BusClient(host='127.0.0.1', port=15555)

print client.request(service='MyService', token='', message=['hello', 'request from PYTHON'])

client.destroy()    

Exemple #3
0
#encoding=utf8
from pyzbus import BusClient

#1)创建接收客户端,id是接收端的唯一标识
client = BusClient(host='127.0.0.1', port=15555,
                   id='local_mq')  #id required to receive

while True:
    #probe防止链接给网络设备切断,发心跳频率为2s
    res = client.recv(probe_interval=2000)  #

    print res

client.destroy()
Exemple #4
0
from pyzbus import BusClient
import time

client = BusClient(host='127.0.0.1', port=15555)

message = ['hello @%s'%time.time()]

result = client.broadcast('MyBroadcast','', message) 
print result

client.destroy()    

Exemple #5
0
from pyzbus import BusClient
import time

client = BusClient(host='127.0.0.1', port=15555)

message = ['hello @%s' % time.time()]

result = client.broadcast('MyBroadcast', '', message)
print result

client.destroy()
Exemple #6
0
from pyzbus import BusClient, AsynCtrl
import time

client = BusClient(host='127.0.0.1', port=15555)

ctrl = AsynCtrl()
ctrl.service = 'MyService' 
ctrl.msg_id = int(time.time())
ctrl.peer_id = 'local_mq'
ctrl.timeout = 2500 #ms

message = ['hello @%s'%time.time()]

result = client.send(ctrl, message) 
print result

client.destroy()    

Exemple #7
0
 def run(self):   
     for i in range(10000):
         client = BusClient()
         client.destroy()
         time.sleep(0.01)
Exemple #8
0
from pyzbus import BusClient, AsynCtrl
import time

client = BusClient(host='127.0.0.1', port=15555)

ctrl = AsynCtrl()
ctrl.service = 'MyService'
ctrl.msg_id = int(time.time())
ctrl.peer_id = 'local_mq'
ctrl.timeout = 2500  #ms

message = ['hello @%s' % time.time()]

result = client.send(ctrl, message)
print result

client.destroy()
Exemple #9
0
from pyzbus import BusClient

client = BusClient(host='127.0.0.1', port=15555)

print client.publish('MyPubSub', '', 'topic1', ['frame1', 'from Python']) 

client.destroy()    

Exemple #10
0
 def run(self):
     client = BusClient()
     for i in range(1000):  #@UnusedVariable
         res = client.request('helloworld', '', bytearray(1024 * 1024))
         print len(res[0])
Exemple #11
0
 def run(self):   
     client = BusClient()
     for i in range(1000): #@UnusedVariable
         res = client.request('helloworld', '', bytearray(1024*1024))
         print len(res[0])
Exemple #12
0
import threading
from pyzbus import BusClient

client = BusClient()


class ClientThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):

        body = 'a' * 10
        for i in range(1000000):  #@UnusedVariable
            try:
                thread = threading.current_thread()
                handle = client.handle
                res = client.request('helloworld', '', body)
                print thread, handle, res
            except Exception, e:
                print e

        client.destroy()


threads = []
for i in range(32):
    t = ClientThread()
    threads.append(t)
for t in threads:
    t.start()