Skip to content

Commit

Permalink
Merge pull request #17 from ykc2428233/main
Browse files Browse the repository at this point in the history
把async异步代码中的time.sleep()替换为asyncio.sleep()
  • Loading branch information
OrangeMiracle authored May 10, 2023
2 parents e5fbb5e + ad69b2a commit c8d85e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions chatGPTQQbot/src/plugins/gpttalk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async def _(event: GroupMessageEvent):
user_msg = event.message
c.execute("SELECT * FROM userinfo WHERE userid = ?", [str(uid)])
row = c.fetchone()
time.sleep(0.5)
await asyncio.sleep(0.5)
account_list = get_gpt_accounts()
if row is not None and not('None' in row[3]):
i = 0
Expand All @@ -173,7 +173,7 @@ async def _(event: GroupMessageEvent):
if((row[2] in email)): #这里需要确认 1.群友上次用的是哪一个账号
if(str(row[3]) in str(account_list[i].bot.get_conversations())): #2.它使用的对话是否还存在
while('working' in account_list[i].status):
time.sleep(0.5)
await asyncio.sleep(0.5)
account_list = get_gpt_accounts()

account_list[i].status = 'working'
Expand Down Expand Up @@ -205,10 +205,10 @@ async def _(event: GroupMessageEvent):
while(True):
log('新用户while')
i = 0
time.sleep(0.5)
await asyncio.sleep(0.5)
account_list = get_gpt_accounts()
for x in account_list:
time.sleep(0.2)
await asyncio.sleep(0.2)
if('working' in x.status): #为啥我要用一个list里面的值表示状态来标记当前任务是否能用呢,因为我还没学会多线程😅
account_list = get_gpt_accounts()
else:
Expand Down Expand Up @@ -286,7 +286,7 @@ async def _(event: GroupMessageEvent):
async def _(event: GroupMessageEvent):
uid=event.user_id
chatgpt.open(refresh=True)
time.sleep(2)
await asyncio.sleep(2)
GPTIO.log(chatgpt.GPT_status)
chatgpt.GPT_status = chatgpt.gptBusyorFree()
GPTIO.log(chatgpt.GPT_status)
Expand Down

0 comments on commit c8d85e9

Please sign in to comment.