Skip to content

Instantly share code, notes, and snippets.

@joeyism
Created January 2, 2020 16:25
Show Gist options
  • Save joeyism/c8c35ec147c8c106641106defef6be2d to your computer and use it in GitHub Desktop.
Save joeyism/c8c35ec147c8c106641106defef6be2d to your computer and use it in GitHub Desktop.
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