Skip to content

Instantly share code, notes, and snippets.

@justnom
Created April 3, 2015 16:03
Show Gist options
  • Save justnom/07ab769b6179c70584aa to your computer and use it in GitHub Desktop.
Save justnom/07ab769b6179c70584aa to your computer and use it in GitHub Desktop.
clear_tube.py
#!/usr/bin/env python
import sys
import beanstalkc
b = beanstalkc.Connection()
b.watch('deadtraffic')
stats = b.stats_tube('deadtraffic')
ready = stats.get('current-jobs-ready')
for x in range(0, ready):
sys.stdout.write('\rClearing {} of {}'.format(x, ready))
sys.stdout.flush()
j = b.reserve(timeout=0)
if j is None:
break
j.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment