本文整理匯總了Python中twisted.protocols.amp.UnknownRemoteError方法的典型用法代碼示例。如果您正苦於以下問題:Python amp.UnknownRemoteError方法的具體用法?Python amp.UnknownRemoteError怎麽用?Python amp.UnknownRemoteError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.protocols.amp
的用法示例。
在下文中一共展示了amp.UnknownRemoteError方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_helloNoErrorHandling
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import UnknownRemoteError [as 別名]
def test_helloNoErrorHandling(self):
"""
Verify that if an unknown error type is raised, it will be relayed to
the other end of the connection and translated into an exception, it
will be logged, and then the connection will be dropped.
"""
L=[]
c, s, p = connectedServerAndClient(
ServerClass=SimpleSymmetricCommandProtocol,
ClientClass=SimpleSymmetricCommandProtocol)
HELLO = THING_I_DONT_UNDERSTAND
c.sendHello(HELLO).addErrback(L.append)
p.flush()
ure = L.pop()
ure.trap(amp.UnknownRemoteError)
c.sendHello(HELLO).addErrback(L.append)
cl = L.pop()
cl.trap(error.ConnectionDone)
# The exception should have been logged.
self.assertTrue(self.flushLoggedErrors(ThingIDontUnderstandError))
示例2: test_helloNoErrorHandling
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import UnknownRemoteError [as 別名]
def test_helloNoErrorHandling(self):
"""
Verify that if an unknown error type is raised, it will be relayed to
the other end of the connection and translated into an exception, it
will be logged, and then the connection will be dropped.
"""
L=[]
c, s, p = connectedServerAndClient(
ServerClass=SimpleSymmetricCommandProtocol,
ClientClass=SimpleSymmetricCommandProtocol)
HELLO = THING_I_DONT_UNDERSTAND
c.sendHello(HELLO).addErrback(L.append)
p.flush()
ure = L.pop()
ure.trap(amp.UnknownRemoteError)
c.sendHello(HELLO).addErrback(L.append)
cl = L.pop()
cl.trap(error.ConnectionDone)
# The exception should have been logged.
self.failUnless(self.flushLoggedErrors(ThingIDontUnderstandError))
示例3: defaultErrback
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import UnknownRemoteError [as 別名]
def defaultErrback(self, failure):
failure.trap(ConnectionAborted, ConnectionClosed, ConnectionDone,
ConnectionLost, UnknownRemoteError)
示例4: defaultErrback
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import UnknownRemoteError [as 別名]
def defaultErrback(self, failure):
failure.trap(ConnectionAborted, ConnectionClosed, ConnectionDone,
ConnectionLost, UnknownRemoteError)
reactor.stop()
示例5: call_responder
# 需要導入模塊: from twisted.protocols import amp [as 別名]
# 或者: from twisted.protocols.amp import UnknownRemoteError [as 別名]
def call_responder(protocol, command, arguments):
"""Call `command` responder in `protocol` with given `arguments`.
Serialises the arguments and deserialises the response too.
"""
responder = protocol.locateResponder(command.commandName)
arguments = command.makeArguments(arguments, protocol)
d = responder(arguments)
d.addCallback(command.parseResponse, protocol)
def eb_massage_error(error):
if error.check(amp.RemoteAmpError):
# Convert remote errors back into local errors using the
# command's error map if possible.
error_type = command.reverseErrors.get(
error.value.errorCode, amp.UnknownRemoteError
)
return Failure(error_type(error.value.description))
else:
# Exceptions raised in responders that aren't declared in that
# responder's schema can get through to here without being wrapped
# in RemoteAmpError. This is because call_responder() bypasses the
# network marshall/unmarshall steps, where these exceptions would
# ordinarily get squashed.
return Failure(
amp.UnknownRemoteError(
"%s: %s"
% (reflect.qual(error.type), reflect.safe_str(error.value))
)
)
d.addErrback(eb_massage_error)
return d