python assertionerror是什么异常_在Python中执行绪时出现AssertionError

1586010002-jmsa.png

I'm trying to run some simple threading in Python using:

t1 = threading.Thread(analysis("samplequery"))

t1.start()

other code runs in here

t1.join()

Unforunately I'm getting the error:

"AssertionError: group argument must be none for now"

I've never implemented threading in Python before, so I'm a bit unsure as to what's going wrong. Does anyone have any idea what the problem is?

I'm not sure if it's relevant at all, but analysis is a method imported from another file.

I had one follow up query as well. Analysis returns a dictionary, how would I go about assigning that for use in the original method?

Thanks

解决方案

You want to specify the target keyword parameter instead:

t1 = threading.Thread(target=analysis("samplequery"))

You probably meant to make analysis the run target, but 'samplequery the argument when started:

t1 = threading.Thread(target=analysis, args=("samplequery",))

The first parameter to Thread() is the group argument, and it currently only accepts None as the argument.

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值