You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import time
import gevent.monkey
gevent.monkey.patch_all()
a = time.time()
mc.set('a', 1)
def add(key):
#with lock:
mc.incr(key)
jobs = []
for i in xrange(1000):
jobs.append(gevent.spawn(add, 'a'))
gevent.joinall(jobs)
print mc.get('a')
mc.delete('a')
print time.time() - a
just like the code above, It gives 995 but 1001 as suppose to be. Is there any idea about this issue?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hey @torpedoallen I guess it is because it is because you are having a race condition, imagine you have 10 threads trying to increment on the same value (and if there is no value, it will start as 0 I think), it is not predicable which will be the outcome.
just like the code above, It gives 995 but 1001 as suppose to be. Is there any idea about this issue?
Thanks in advance.
The text was updated successfully, but these errors were encountered: