本文整理匯總了Python中wishbone.event.Event類的典型用法代碼示例。如果您正苦於以下問題:Python Event類的具體用法?Python Event怎麽用?Python Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_event_appendBulk
def test_event_appendBulk():
e = Event(bulk=True)
ee = Event({"one": 1})
e.appendBulk(ee)
assert e.dump()["data"][0]["uuid"] == ee.data["uuid"]
示例2: test_module_unpack
def test_module_unpack():
actor_config = ActorConfig('unpack', 100, 1, {}, "")
unpack = Unpack(actor_config)
unpack.pool.queue.inbox.disableFallThrough()
unpack.pool.queue.outbox.disableFallThrough()
unpack.start()
bulk = Event(bulk=True)
for _ in range(0, 10):
bulk.appendBulk(Event())
unpack.pool.queue.inbox.put(bulk)
for _ in range(0, 10):
assert getter(unpack.pool.queue.outbox)
try:
getter(unpack.pool.queue.outbox)
except Exception:
assert True
else:
assert False
示例3: test_module_fanout
def test_module_fanout():
actor_config = ActorConfig('fanout', 100, 1, {})
fanout = Fanout(actor_config, deep_copy=True)
fanout.pool.queue.inbox.disableFallThrough()
fanout.pool.createQueue("one")
fanout.pool.queue.one.disableFallThrough()
fanout.pool.createQueue("two")
fanout.pool.queue.two.disableFallThrough()
fanout.start()
e = Event('test')
e.setData("hello")
fanout.pool.queue.inbox.put(e)
one = getter(fanout.pool.queue.one)
two = getter(fanout.pool.queue.two)
fanout.stop()
assert one.raw()["test"]["data"] == "hello"
assert two.raw()["test"]["data"] == "hello"
assert id(one) != id(two)
示例4: test_event_clone
def test_event_clone():
a = Event({"one": 1, "two": 2})
b = a.clone()
assert id(a.data) != id(b.data)
assert not a.data["cloned"]
assert b.data["cloned"]
assert b.data["uuid_previous"][0] == a.data["uuid"]
示例5: test_event_get_error
def test_event_get_error():
e = Event({"one": 1, "two": {"three": 3}})
try:
e.get("data.blah")
except KeyError:
assert True
else:
assert False
示例6: test_event_render_error
def test_event_render_error():
e = Event({"one": 1, "two": 2})
try:
e.render("{{data.one} is a number and so is {{data.two}}")
except InvalidData:
assert True
else:
assert False
示例7: test_merge_fail
def test_merge_fail():
e = Event("hi")
try:
e.merge(["two"])
except InvalidData:
assert True
else:
assert False
示例8: test_extractBulkItems
def test_extractBulkItems():
from wishbone.event import extractBulkItems
e = Event(bulk=True)
e.appendBulk(Event({"one": 1}))
e.appendBulk(Event({"two": 2}))
e.appendBulk(Event({"three": 3}))
for item in extractBulkItems(e):
assert isinstance(item, Event)
示例9: test_event_delete
def test_event_delete():
a = Event({"one": 1, "two": 2})
a.delete("data.two")
try:
a.get("data.two")
except KeyError:
assert True
else:
assert False
示例10: test_extractBulkItemValues
def test_extractBulkItemValues():
from wishbone.event import extractBulkItemValues
e = Event(bulk=True)
e.appendBulk(Event({"one": 1}))
e.appendBulk(Event({"two": 2}))
e.appendBulk(Event({"three": 3}))
for item in extractBulkItemValues(e, "data"):
assert item in [{"one": 1}, {"two": 2}, {"three": 3}]
示例11: __log
def __log(self, level, message):
event = Event(self.name)
event.data = Log(time(), level, getpid(), self.name, message)
while True:
try:
self.logs.put(event)
break
except QueueFull:
sleep(0.1)
示例12: metricProducer
def metricProducer(self):
'''A greenthread which collects the queue metrics at the defined interval.'''
self.__run.wait()
hostname = socket.gethostname()
while self.loop():
for queue in self.pool.listQueues(names=True):
for metric, value in self.pool.getQueue(queue).stats().iteritems():
event = Wishbone_Event(self.name)
event.data = Metric(time=time(), type="wishbone", source=hostname, name="module.%s.queue.%s.%s" % (self.name, queue, metric), value=value, unit="", tags=())
self.submit(event, self.pool.queue.metrics)
sleep(self.frequency)
示例13: test_event_slurp_bad
def test_event_slurp_bad():
a = Event()
del(a.data["uuid"])
b = Event()
try:
b.slurp(a.dump())
except InvalidData:
assert True
else:
assert False
示例14: test_event_appendBulkFull
def test_event_appendBulkFull():
e = Event(bulk=True, bulk_size=1)
ee = Event({"one": 1})
e.appendBulk(ee)
try:
e.appendBulk(ee)
except BulkFull:
assert True
else:
assert False
示例15: processEvent
def processEvent(self, data, meta, queue):
'''
The callback executed for each Wishbone event to be created out of a
single http request.
'''
e = Event(data)
e.set(meta, 'tmp.%s' % (self.name))
e.renderKwargs(self.kwargs_template)
self.submit(e, queue)
return self.getResponse(e, queue)