Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lack of time.sleep(1) #971

Open
5 tasks
orangelzh opened this issue Oct 14, 2022 · 5 comments
Open
5 tasks

lack of time.sleep(1) #971

orangelzh opened this issue Oct 14, 2022 · 5 comments

Comments

@orangelzh
Copy link

在提交前,请确保您已经检查了以下内容!

  • 您可以在浏览器中登陆微信账号,但不能使用itchat登陆
  • 我已经阅读并按文档 中的指引进行了操作
  • 您的问题没有在issues报告,否则请在原有issue下报告
  • 本问题确实关于itchat, 而不是其他项目.
  • 如果你的问题关于稳定性,建议尝试对网络稳定性要求极低的itchatmp项目

请使用itchat.run(debug=True)运行,并将输出粘贴在下面:

[在这里粘贴完整日志]

您的itchat版本为:[在这里填写版本号]。(可通过python -c "import itchat;print(itchat.__version__)"获取)

其他的内容或者问题更详细的描述都可以添加在下面:

[您的内容]

    while not isLoggedIn:
        status = self.check_login()
        if hasattr(qrCallback, '__call__'):
            qrCallback(uuid=self.uuid, status=status, qrcode=qrStorage.getvalue())
        if status == '200':
            isLoggedIn = True
        elif status == '201':
            if isLoggedIn is not None:
                logger.info('Please press confirm on your phone.')
                isLoggedIn = None
        elif status != '408':
            break
        # time.sleep(1) 

这里 while 循环体 没有 time.sleep(1) 导致 请求 太频繁被微信拦截。

@wellcoming
Copy link

useful

@hxq28
Copy link

hxq28 commented Nov 4, 2022 via email

@zhaohuiwei1990
Copy link

zhaohuiwei1990 commented Nov 4, 2022 via email

@wellcoming
Copy link

async版

         elif status != '408':
            payload = EventScanPayload(
                status=ScanStatus.Cancel,
                qrcode=f"https://login.weixin.qq.com/l/{self.uuid}"
            )
            event_stream.emit('scan', payload)
            await asyncio.sleep(0.1)
            break
        await asyncio.sleep(1)
    if isLoggedIn:
        payload = EventScanPayload(
            status=ScanStatus.Confirmed,
            qrcode=f"https://login.weixin.qq.com/l/{self.uuid}"
        )

@fungaren
Copy link

LOCATION=$(pip3 show itchat | grep Location | cut -d ' ' -f 2)
sed -i '/isLoggedIn = False/ a\        time.sleep(15)' $LOCATION/itchat/components/login.py
sed -i '/isLoggedIn = False/ a\        asyncio.sleep(15)' $LOCATION/itchat/async_components/login.py
sed -i '/if isLoggedIn:/ i\            time.sleep(1)' $LOCATION/itchat/components/login.py
sed -i '/if isLoggedIn:/ i\            asyncio.sleep(1)' $LOCATION/itchat/async_components/login.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants