I have the blocking code shown below.

Is calling monkey.patch_all() enough/optimal to make it non-blocking?

Does Gevent handle iterations like these?

# front page
def front_page():
    database = db.posts.find() # find all items in posts collection

    return render_template(

# single post
def single_post(slug):
    post = [v for k,v 
                in db.posts.find_one(
                                     {'slug': slug}
           ] # iterate over found items and store it as post

    return render_template(
                          ) # extract the title, slug and body
  • 3
    Did you check this question with google first? Did you check the documentation for gevent first? – Zeroth Apr 16 '14 at 15:45
  • 1
    @Zeroth Yes, but someone says that Monkey-patching does all for you, the other says that it's better to replace the code with its async counterpart because patching is evil. I don't know what advice to follow actually. I would feel better if I knew how to replace those calls with their async alternative effectively though.. – user3535094 Apr 16 '14 at 15:48
  • 1
    Do you know what the monkey patching is doing? Have you looked up how to use the async alternatives yet? – Zeroth Apr 16 '14 at 15:58
  • @Zeroth It should replace every blocking call with its non-blocking counterpart? – user3535094 Apr 16 '14 at 16:13
  • So, is this okay: – user3535094 Apr 16 '14 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.