Created
January 2, 2020 16:25
-
-
Save joeyism/c8c35ec147c8c106641106defef6be2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch.multiprocessing as mp | |
QUEUE_SIZE = mp.Value('i', 0) | |
def _decrease_queue(): | |
with QUEUE_SIZE.get_lock(): | |
QUEUE_SIZE.value -= 1 | |
def _increase_queue(): | |
with QUEUE_SIZE.get_lock(): | |
QUEUE_SIZE.value += 1 | |
def queue_size(): | |
return QUEUE_SIZE.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment