本文整理汇总了Python中proton.reactor.Reactor.schedule方法的典型用法代码示例。如果您正苦于以下问题:Python Reactor.schedule方法的具体用法?Python Reactor.schedule怎么用?Python Reactor.schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proton.reactor.Reactor
的用法示例。
在下文中一共展示了Reactor.schedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExceptionTest
# 需要导入模块: from proton.reactor import Reactor [as 别名]
# 或者: from proton.reactor.Reactor import schedule [as 别名]
#.........这里部分代码省略.........
c = self.reactor.connection()
s = c.session()
s.handler = object()
s.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_link_set(self):
c = self.reactor.connection()
s = c.session()
l = s.sender("xxx")
l.handler = BarfOnInit()
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_link_add(self):
c = self.reactor.connection()
s = c.session()
l = s.sender("xxx")
l.handler = object()
l.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_schedule(self):
self.reactor.schedule(0, BarfOnTask())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_schedule_many_nothings(self):
class Nothing:
results = []
def on_timer_task(self, event):
self.results.append(None)
num = 12345
for a in range(num):
self.reactor.schedule(0, Nothing())
self.reactor.run()
assert len(Nothing.results) == num
def test_schedule_many_nothing_refs(self):
class Nothing:
results = []
def on_timer_task(self, event):
self.results.append(None)
num = 12345
tasks = []
for a in range(num):
tasks.append(self.reactor.schedule(0, Nothing()))
self.reactor.run()
示例2: ExceptionTest
# 需要导入模块: from proton.reactor import Reactor [as 别名]
# 或者: from proton.reactor.Reactor import schedule [as 别名]
#.........这里部分代码省略.........
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_reactor_set(self):
self.reactor.handler = BarfOnInit()
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_reactor_add(self):
self.reactor.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_connection(self):
self.reactor.connection(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_connection_set(self):
c = self.reactor.connection()
c.handler = BarfOnInit()
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_connection_add(self):
c = self.reactor.connection()
c.handler = object()
c.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_session_set(self):
c = self.reactor.connection()
s = c.session()
s.handler = BarfOnInit()
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_session_add(self):
c = self.reactor.connection()
s = c.session()
s.handler = object()
s.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_link_set(self):
c = self.reactor.connection()
s = c.session()
l = s.sender("xxx")
l.handler = BarfOnInit()
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_link_add(self):
c = self.reactor.connection()
s = c.session()
l = s.sender("xxx")
l.handler = object()
l.handler.add(BarfOnInit())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass
def test_schedule(self):
self.reactor.schedule(0, BarfOnTask())
try:
self.reactor.run()
assert False, "expected to barf"
except Barf:
pass