会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133791个问题

import threading
import time
from queue import Queue
class Pro(threading.Thread):
    def run(self):
        global qu
        count=0
        while True:
            if qu.qsize()<1000:
                for i in range(100):
                    count+=1
                    msg="生成产品"+str(count)
                    qu.put(msg)
                    print(msg)
            time.sleep(1)
class Con(threading.Thread):
    def run(self):
        global qu
        while True:
            if qu.qsize()>100:
                for i in range(3):
                    msg=self.name+"消费了"+qu.get()
                    print(msg)
            time.sleep(1)
if __name__=="__main__":
    qu=Queue
    for i in range(500):
        qu.put("初始产品"+str(i),)
    for i in range(2):
        p=Pro()
        p.start()
    for i in range(5):
        c=Con()
        c.start()

代码跟老师的一样,为什么会报这样的错??????????

Traceback (most recent call last):

  File "C:/Users/齐泉/PycharmProjects/1/test2.py", line 28, in <module>

    qu.put("初始产品"+str(i))

TypeError: put() missing 1 required positional argument: 'item'


Process finished with exit code 1


Python 全系列/第三阶段:Python 网络与并发编程/并发编程 32206楼
Python 全系列/第三阶段:Python 网络与并发编程/并发编程 32207楼
Python 全系列/第二十阶段:数据分析-数据管理/数据分析案例_案例1_足球运动员分析 32209楼
Python 全系列/第十阶段:前端进阶-高效开发Vue框架/Vue3 32210楼
JAVA 全系列/第八阶段:Linux入门到实战/Maven 32211楼
JAVA 全系列/第八阶段:Linux入门到实战/Maven 32212楼
JAVA 全系列/第九阶段:Spring Boot实战/Spring Boot 32218楼

org.apache.dubbo.rpc.RpcException: Failed to invoke the method registerCheckCode in the service com.itbaizhan.shopping_common.service.ShoppingUserService. Tried 3 times of the providers [192.168.1.9:20880] (1/1) from the registry 192.168.66.106:2181 on the consumer 192.168.79.1 using the dubbo version 2.7.8. Last error is: Invoke remote method timeout. method: registerCheckCode, provider: dubbo://192.168.1.9:20880/com.itbaizhan.shopping_common.service.ShoppingUserService?anyhost=true&application=shopping_user_customer_api&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&init=false&interface=com.itbaizhan.shopping_common.service.ShoppingUserService&metadata-type=remote&methods=getName,registerCheckCode,saveLoginCheckCode,loginPassword,getLoginUser,loginCheckCode,saveRegisterCheckCode,register&pid=33084&qos.enable=false&register.ip=192.168.79.1&release=2.7.8&remote.application=shopping_user_service&side=consumer&sticky=false&timestamp=1695463365954, cause: org.apache.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer. start time: 2023-09-23 18:17:30.813, end time: 2023-09-23 18:17:31.826, client elapsed: 1 ms, server elapsed: 1012 ms, timeout: 1000 ms, request: Request [id=12, version=2.0.2, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=registerCheckCode, parameterTypes=[class java.lang.String, class java.lang.String], arguments=[13315223589, 8333], attachments={path=com.itbaizhan.shopping_common.service.ShoppingUserService, remote.application=shopping_user_customer_api, interface=com.itbaizhan.shopping_common.service.ShoppingUserService, version=0.0.0}]], channel: /192.168.1.9:8882 -> /192.168.1.9:20880

,验证用户验证码时,报以上错误,老师看下这个问题

JAVA 全系列/第十九阶段:亿级高并发电商项目/亿级高并发电商项目(旧) 32219楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637