这是我的代码,但它在尝试连接时会无休止地等待
你知道怎么“修复”它吗? 短暂性脑缺血发作
import aioxmpp
import asyncio
jid = aioxmpp.JID.fromstr('myuser@gmail.com')
password = 'myPassToGmailAccount'
recipient_jid = aioxmpp.JID.fromstr('recipient_email@gmail.com')
client1 = aioxmpp.PresenceManagedClient(
jid,aioxmpp.make_security_layer(password))
client1.presence = aioxmpp.PresenceState(available=True,
show=aioxmpp.PresenceShow.CHAT)
print (client1.running) # print True
async def send_chat_msg():
print('hw') # this one is printed and then wait endlessly
async with client1.connected() as stream:
print('hw1') # never print it since hang on the previous command
msg = aioxmpp.Message(to=recipient_jid,type_=aioxmpp.MessageType.CHAT,)
msg.body[None] = "Hello World!"
await client1.send(msg)
if __name__ == '__main__':
asyncio.run(send_chat_msg())
目前没有回答
相关问题 更多 >
编程相关推荐