Python -进程

进程编号:

1.当前执行的代码的name : multiprocessing.current_process ( )

2.当前的进程编号 : multiprocessing.current_process() . pid

3.父进程编号:os.getppid ( )

4.当前的进程编号+ 父进程编号 :multiprocessing.current_process() . pid , os.getppid ()

print("当前执行的代码的name :",multiprocessing.current_process ())

print ("当前的进程编号 :", multiprocessing.current_process().pid)

print ("父进程编号:", os.getppid())

print("当前的进程编号+ 父进程编号 :",multiprocessing.current_process() pid   os.getppid())

当前执行的代码的 name : <_MainProcess(MainProcess, started)>
当前的进程编号 : 6748
父进程编号: 3496
当前的进程编号+ 父进程编号 : 6748 3496


消息队列:

消息队列 上限 : q = multiprocessing . Queue ( 3 )
添加内容: q. put( “内容”)
加载内容: q . get( )


  • Queue.qsize():返回当前队列包含的消息数量;
  • Queue.empty():如果队列为空,返回True,反之False , 注意这个操作是不可靠的。
  • Queue.full():如果队列满了,返回True,反之False;

c = q.full()
print("是否满了:",  c )   


time.sleep(0.01)
d = q.empty()
print("是否空了:"  , d )


if q.qsize( ) ==  0 :
    print(  "满了" )
else:
    print(  "没"   )

这里写图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值