本文整理汇总了Python中aplus.Promise.rejected方法的典型用法代码示例。如果您正苦于以下问题:Python Promise.rejected方法的具体用法?Python Promise.rejected怎么用?Python Promise.rejected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aplus.Promise
的用法示例。
在下文中一共展示了Promise.rejected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_command
# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import rejected [as 别名]
def send_command(self, name, args=None, callback=None):
promise = Promise()
msg = {
"name": name,
"id": str(self.seq),
"args": args or []
}
msg_enc = json.dumps(msg, separators=(',', ':'))
try:
with self.ws_lock:
if self.ws is None or self.state == SpotifyAPI.DISCONNECTED:
return Promise.rejected(SpotifyDisconnectedError())
pid = self.seq
if callback:
promise.addCallback(callback)
self.cmd_promises[pid] = promise
self.seq += 1
self.ws.send(msg_enc)
logger.debug("Sent PID({}) with msg: {}".format(pid, msg_enc))
except (SSLError, StreamClosed) as e:
logger.error("SSL error ({}), attempting to continue".format(e))
promise.rejected(SpotifyDisconnectedError())
return promise
示例2: test_rejected
# 需要导入模块: from aplus import Promise [as 别名]
# 或者: from aplus.Promise import rejected [as 别名]
def test_rejected():
p = Promise.rejected(Exception("Static rejected"))
assert p.isRejected
assert_exception(p.reason, Exception, "Static rejected")