如何知道python信号量值

2024-04-16 17:20:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我在代码中使用threading.semaphore,我想知道是否有方法可以使用这样的代码

if(sema.acquire()!=True):
   #do Somthing

我想在循环中使用这段代码,所以我需要得到信号量是被接受还是被释放 或者在我的代码中使用这样的代码

if(sema.get_value!=1):
  #do something

我读过这个医生,但找不到答案 https://docs.python.org/3/library/threading.html


Tags: 方法代码truegetifvaluedosomething