用法:
wait(timeout=None)
通过障碍。当屏障的所有线程都调用了这个函数时,它们都被同时释放。如果提供了
timeout
,则它优先于提供给类构造函数的任何内容使用。返回值是 0 到
parties
- 1 范围内的整数,每个线程都不同。这可以用来选择一个线程来做一些特殊的家务,例如:i = barrier.wait() if i == 0: # Only one thread needs to print this print("passed the barrier")
如果向构造函数提供了
action
,则其中一个线程将在释放之前调用它。如果此调用引发错误,则屏障将进入损坏状态。如果调用超时,屏障将进入破坏状态。
如果在线程等待时屏障被破坏或重置,此方法可能会引发
BrokenBarrierError
异常。
相关用法
- Python threading get_native_id()用法及代码示例
- Python threading enumerate()用法及代码示例
- Python threading get_ident()用法及代码示例
- Python threading active_count()用法及代码示例
- Python threading main_thread()用法及代码示例
- Python threading stack_size()用法及代码示例
- Python threading current_thread()用法及代码示例
- Python threading setprofile()用法及代码示例
- Python threading settrace()用法及代码示例
- Python torch.distributed.rpc.rpc_async用法及代码示例
- Python torch.nn.InstanceNorm3d用法及代码示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代码示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代码示例
- Python torchaudio.transforms.Fade用法及代码示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代码示例
- Python tf.summary.scalar用法及代码示例
- Python tf.linalg.LinearOperatorFullMatrix.matvec用法及代码示例
- Python tf.linalg.LinearOperatorToeplitz.solve用法及代码示例
- Python tf.raw_ops.TPUReplicatedInput用法及代码示例
- Python tf.raw_ops.Bitcast用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 threading.Barrier.wait。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。