本文整理汇总了Python中aiohttp.connector.Connection.add_callback方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.add_callback方法的具体用法?Python Connection.add_callback怎么用?Python Connection.add_callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiohttp.connector.Connection
的用法示例。
在下文中一共展示了Connection.add_callback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_callbacks_on_release
# 需要导入模块: from aiohttp.connector import Connection [as 别名]
# 或者: from aiohttp.connector.Connection import add_callback [as 别名]
def test_callbacks_on_release(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
notified = False
def cb():
nonlocal notified
notified = True
conn.add_callback(cb)
conn.release()
assert notified
示例2: test_callbacks_on_detach
# 需要导入模块: from aiohttp.connector import Connection [as 别名]
# 或者: from aiohttp.connector.Connection import add_callback [as 别名]
def test_callbacks_on_detach(connector, key, protocol, loop):
conn = Connection(connector, key, protocol, loop)
notified = False
def cb():
nonlocal notified
notified = True
conn.add_callback(cb)
conn.detach()
assert notified
示例3: test_callbacks_exception
# 需要导入模块: from aiohttp.connector import Connection [as 别名]
# 或者: from aiohttp.connector.Connection import add_callback [as 别名]
def test_callbacks_exception(connector, key, protocol, loop) -> None:
conn = Connection(connector, key, protocol, loop)
notified = False
def cb1():
raise Exception
def cb2():
nonlocal notified
notified = True
conn.add_callback(cb1)
conn.add_callback(cb2)
conn.close()
assert notified