Skip to content

Instantly share code, notes, and snippets.

@bzdgn
Last active August 29, 2015 14:23
Show Gist options
  • Save bzdgn/2e122f33678c91a1c340 to your computer and use it in GitHub Desktop.
Save bzdgn/2e122f33678c91a1c340 to your computer and use it in GitHub Desktop.
Python Memcached Client Script
#!/user/bin/env python
import os
from time import sleep
import subprocess
import memcache
mclient = memcache.Client(['127.0.0.1:11211'], debug=0)
try:
while(True):
sleep(0.1)
user = mclient.get("user")
if(user!="clientA"):
mclient.set("user","clientA")
print("clientA: takeover")
except KeyboardInterrupt:
mclient.delete("user")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment