Skip to content

Instantly share code, notes, and snippets.

@hikoz
Created March 30, 2010 08:54
Show Gist options
  • Save hikoz/348928 to your computer and use it in GitHub Desktop.
Save hikoz/348928 to your computer and use it in GitHub Desktop.
import time
import multiprocessing
import memcache
key = 'foo'
process = 100
count = 1000
def f():
mc = memcache.Client(['127.0.0.1:11212'])
for i in range(count):
mc.incr(key)
while 1:
mc = memcache.Client(['127.0.0.1:11212'])
mc.set(key, 1)
assert mc.get(key) == 1
l = []
for i in range(process):
p = multiprocessing.Process(target=f)
p.start()
l.append(p)
for p in l:
p.join()
time.sleep(1)
print mc.get(key)
assert mc.get(key) == process * count + 1
time.sleep(10)
# ubuntu 9.04
# memcached Version: 1.2.2-1+lenny1build0.9.04.1
# libevent1 Version: 1.3e-3
# 100回試行して再現せず
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment