当前位置: 首页>>代码示例>>Python>>正文


Python multiprocessing.AuthenticationError方法代码示例

本文整理汇总了Python中multiprocessing.AuthenticationError方法的典型用法代码示例。如果您正苦于以下问题:Python multiprocessing.AuthenticationError方法的具体用法?Python multiprocessing.AuthenticationError怎么用?Python multiprocessing.AuthenticationError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing的用法示例。


在下文中一共展示了multiprocessing.AuthenticationError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_answer_challenge_auth_failure

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import AuthenticationError [as 别名]
def test_answer_challenge_auth_failure(self):
        class _FakeConnection(object):
            def __init__(self):
                self.count = 0
            def recv_bytes(self, size):
                self.count += 1
                if self.count == 1:
                    return multiprocessing.connection.CHALLENGE
                elif self.count == 2:
                    return b'something bogus'
                return b''
            def send_bytes(self, data):
                pass
        self.assertRaises(multiprocessing.AuthenticationError,
                          multiprocessing.connection.answer_challenge,
                          _FakeConnection(), b'abc')

#
# Test Manager.start()/Pool.__init__() initializer feature - see issue 5585
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_multiprocessing.py

示例2: test_deliver_challenge_auth_failure

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import AuthenticationError [as 别名]
def test_deliver_challenge_auth_failure(self):
        class _FakeConnection(object):
            def recv_bytes(self, size):
                return b'something bogus'
            def send_bytes(self, data):
                pass
        self.assertRaises(multiprocessing.AuthenticationError,
                          multiprocessing.connection.deliver_challenge,
                          _FakeConnection(), b'abc') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_multiprocessing.py

示例3: deliver_challenge

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import AuthenticationError [as 别名]
def deliver_challenge(connection, authkey):
    import hmac
    assert isinstance(authkey, bytes)
    message = os.urandom(MESSAGE_LENGTH)
    connection.send_bytes(CHALLENGE + message)
    digest = hmac.new(authkey, message).digest()
    response = connection.recv_bytes(256)        # reject large message
    if response == digest:
        connection.send_bytes(WELCOME)
    else:
        connection.send_bytes(FAILURE)
        raise AuthenticationError('digest received was wrong') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:connection.py

示例4: answer_challenge

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import AuthenticationError [as 别名]
def answer_challenge(connection, authkey):
    import hmac
    assert isinstance(authkey, bytes)
    message = connection.recv_bytes(256)         # reject large message
    assert message[:len(CHALLENGE)] == CHALLENGE, 'message = %r' % message
    message = message[len(CHALLENGE):]
    digest = hmac.new(authkey, message).digest()
    connection.send_bytes(digest)
    response = connection.recv_bytes(256)        # reject large message
    if response != WELCOME:
        raise AuthenticationError('digest sent was rejected')

#
# Support for using xmlrpclib for serialization
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:connection.py

示例5: run

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import AuthenticationError [as 别名]
def run(self, host, port):
        """ Run a similarity server serving requests that come in at the given port """
        address = (host, port)  # Family is deduced to be 'AF_INET'
        # Load the secret password that clients must use to authenticate themselves
        try:
            with open("resources/SimilarityServerKey.txt", "rb") as file:
                secret_password = file.read()
        except FileNotFoundError:
            raise InternalError(
                "Server key file missing: resources/SimilarityServerKey.txt"
            )
        except:
            raise InternalError(
                "Unable to load server key when starting similarity server"
            )

        print(
            "Greynir similarity server started\nListening for connections on port {0}".format(
                port
            )
        )

        with Listener(address, authkey=secret_password) as listener:
            self._corpus = ReynirCorpus()
            self._load_topics()
            while True:
                try:
                    conn = listener.accept()
                    print("Connection accepted from {0}".format(listener.last_accepted))
                    # Launch a thread to handle commands from this client
                    Thread(target=self._command_loop, args=(conn,)).start()
                except AuthenticationError:
                    print("Authentication failed for client")
                    pass
                except Exception as ex:
                    print("Exception when listening for connections: {0}".format(ex))
                    pass
                finally:
                    sys.stdout.flush() 
开发者ID:mideind,项目名称:Greynir,代码行数:41,代码来源:simserver.py


注:本文中的multiprocessing.AuthenticationError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。