Exemplo n.º 1
0
def testspeed(total=1):
    p = Pubsub(listen=False)
    j = p.job("jobtest")
    start = time.time()
    for x in range(1, total + 1):
        j.publish(x)
    tt = time.time() - start
    print(tt, total / tt)
Exemplo n.º 2
0
def runjobs(listen=False):
    p = Pubsub()
    job_channel = p.job("jobtest")
    x = 0
    starttime = time.time()
    while True:
        id, query = job_channel.get()
        #if x%2:
        job_channel.finish(id, query)
        x += 1
        if time.time() > starttime + 1.0:
            print("%d/sec" % x)
            x = 0
            starttime = time.time()
Exemplo n.º 3
0
from thoonk import Pubsub

p = Pubsub()
n = p.feed("test")
id = n.publish("hayyyyyy", id='crap')
print(id, n.get_item(id))
q = p.queue("queue_test")
q.publish("whatever")
q.publish("shit ")
q.publish("whatever")
q.publish("whatever")
q.publish("whatever")
while True:
    try:
        print(q.get(timeout=1))
    except q.Empty:
        break
print("done")

Exemplo n.º 4
0
from flask import Flask, render_template, redirect, request
from thoonk import Pubsub

app = Flask(__name__)
# can specify redis host here , meanwhile piggyback on localhost
app._pubsub = Pubsub(listen=False)

from WorkFlowManagerAPI.app.controllers import notification_controller
 def connect(self):
     return Pubsub(host=self.host,
                   port=self.port,
                   db=self.db,
                   listen=self.listen)