Created
December 19, 2011 11:03
-
-
Save bbrodriges/1496660 to your computer and use it in GitHub Desktop.
Loadimpact test of bottle+gevent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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