Skip to content

Instantly share code, notes, and snippets.

@shishirsharma
Last active December 13, 2015 17:27
Show Gist options
  • Save shishirsharma/74a328e5a8491bbdf0b2 to your computer and use it in GitHub Desktop.
Save shishirsharma/74a328e5a8491bbdf0b2 to your computer and use it in GitHub Desktop.
# Config Part
import dnd
dnd.configure(host='localhost', port=6379, db=0)
# Set Rules
dnd.config.rule.add('notification', 'promotion', 60)
# Enforce Uses
array = []
with dnd.throttle('notification', 10, 'promotion') as pipe:
if pipe: array.append(1)
with dnd.throttle('notification', 10, 'promotion') as pipe:
if pipe: array.append(2)
print array
# [1]
Do Not Disturb
pip install dnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment