Skip to content

Instantly share code, notes, and snippets.

@bbrodriges
Created December 19, 2011 11:03
Show Gist options
  • Save bbrodriges/1496660 to your computer and use it in GitHub Desktop.
Save bbrodriges/1496660 to your computer and use it in GitHub Desktop.
Loadimpact test of bottle+gevent
from gevent import monkey; monkey.patch_all()
import bottle, random, pymongo
db = pymongo.Connection().tinchy.links
def generate_tinchy_id():
return ''.join( random.sample( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890' , 5 ) )
@bottle.route('/')
def make_tinchy_url():
tinchy_id = generate_tinchy_id()
while db.find_one( {'tinchy':tinchy_id} ):
tinchy_id = generate_tinchy_id()
db.insert({'tinchy':tinchy_id})
return 'Inserted'
bottle.run(host='0.0.0.0', port=80, server='gevent')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment