Skip to content

Instantly share code, notes, and snippets.

@mnunberg
Created June 5, 2013 23:37
Show Gist options
  • Select an option

  • Save mnunberg/5718194 to your computer and use it in GitHub Desktop.

Select an option

Save mnunberg/5718194 to your computer and use it in GitHub Desktop.
gevent+couchbase
#!/usr/bin/env python
import gevent
import gevent.monkey; gevent.monkey.patch_all()
from threading import Lock
import sys
from couchbase.libcouchbase import Connection
from couchbase.iops.select import SelectIOPS
def test(x):
c = Connection(bucket='default', iops=SelectIOPS())
c.set("tmp-" + str(x), 1)
sys.stdout.write(str(x) + " ")
sys.stdout.flush()
print("Gevent starting..")
gevent.joinall([gevent.spawn(test, x) for x in xrange(100)])
print("")
Gevent starting..
1 2 5 3 13 4 14 12 11 29 21 25 24 23 26 31 27 0 28 30 6 7 8 9 10 19 22 97 98 99 96 95 94 93 91 92 90 88 89 86 87 85 84 80 83 82 72 81 76 79 78 77 73 75 71 74 69 70 66 65 64 68 63 67 62 61 60 58 57 54 59 53 45 52 55 56 48 46 47 37 50 51 49 38 39 41 42 40 43 44 36 32 33 15 35 34 17 16 18 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment