Skip to content

条件顾问使用,效率有所下降? #26

@xiaochenr1981

Description

@xiaochenr1981

根据大佬的例子,我是用原来的machine_lib把alpha list存入json文件,然后读出后用wqb跑的,但是看起来效率没有提升反而下降了(一小时才50来个),是我还是条件顾问(目前是参加的iqc)只能3个线程的原因吗?还是哪里有问题。以下是我用的简单代码,去掉了登陆和日志部分:

import json

import datetime

from wqb import WQBSession, print

import wqb

def read_json_file(file_path):

try:

    withopen(file_path, 'r') asfile:

    data=json.load(file)

    returndata

exceptFileNotFoundError:

    print(f"文件 {file_path} 未找到")

    returnNone

exceptjson.JSONDecodeErrorase:

    print(f"JSON解码错误: {e}")

    returnNone

def on_success(vars: dict[str, object]) -> None:

wqbs: wqb.WQBSession=vars['self']

nn="002"

dd=datetime.date.today()

os_name=str(dd.strftime("%Y%m%d")) +str(nn)

#修改alpha的name

alpha_id=vars['resp'].json()['alpha']

#print(alpha_id+" name is :"+os_name)

resp=wqbs.patch_properties(

     alpha_id,

     name=os_name, # '<name>'

     log=None,

 )

file_path = 'list_alpha.json'

result = read_json_file(file_path)

if result:

 concurrency=3

 try:

     resps=awaitwqbs.concurrent_simulate(result,concurrency,on_success=on_success,log_gap=10)

     print('alpha_ids:', *(resp.json()['alpha'] forrespinresps), sep='\n')

 exceptException as e:

     print(f"发生错误:{e}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions