本文整理汇总了Python中cryptography.hazmat.bindings.openssl.binding.Binding._lock_cb方法的典型用法代码示例。如果您正苦于以下问题:Python Binding._lock_cb方法的具体用法?Python Binding._lock_cb怎么用?Python Binding._lock_cb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptography.hazmat.bindings.openssl.binding.Binding
的用法示例。
在下文中一共展示了Binding._lock_cb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fallback_crypto_lock_via_binding_api
# 需要导入模块: from cryptography.hazmat.bindings.openssl.binding import Binding [as 别名]
# 或者: from cryptography.hazmat.bindings.openssl.binding.Binding import _lock_cb [as 别名]
def test_fallback_crypto_lock_via_binding_api(self):
b = Binding()
b.init_static_locks()
self._skip_if_not_fallback_lock(b)
lock = b._locks[b.lib.CRYPTO_LOCK_SSL]
with pytest.raises(RuntimeError):
b._lock_cb(0, b.lib.CRYPTO_LOCK_SSL, "<test>", 1)
# errors shouldn't cause locking
assert lock.acquire(False)
lock.release()
b._lock_cb(b.lib.CRYPTO_LOCK | b.lib.CRYPTO_READ,
b.lib.CRYPTO_LOCK_SSL, "<test>", 1)
# locked
assert not lock.acquire(False)
b._lock_cb(b.lib.CRYPTO_UNLOCK | b.lib.CRYPTO_READ,
b.lib.CRYPTO_LOCK_SSL, "<test>", 1)
# unlocked
assert lock.acquire(False)
lock.release()