Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:26:16+00:00 2026-06-16T00:26:16+00:00

Look, people. We have a question about gevent.pool class and pool.wait_available() method, both code

  • 0

Look, people. We have a question about gevent.pool class and pool.wait_available() method, both code snippets

1.

def fetch(url):
    print 'start fetching...', url
    data = urllib2.urlopen(url)
    print url,':',data.code

urls = ['http://www.google.ru', 'http://www.s-str.ru', 'http://www.vk.com', 'http://www.yandex.ru', 'http://www.xxx.com']

pool = Pool(2)

def producer():
    for url in urls:
        pool.spawn(fetch, url)
    pool.join()

p = gevent.spawn(producer)
p.join()

2.

def fetch(url):
    print 'start fetching...', url
    data = urllib2.urlopen(url)
    print url,':',data.code

urls = ['http://www.google.ru', 'http://www.s-str.ru', 'http://www.vk.com', 'http://www.yandex.ru', 'http://www.xxx.com']

pool = Pool(2)

def producer():
    for url in urls:
        pool.wait_available()
        pool.spawn(fetch, url)
    pool.join()

p = gevent.spawn(producer)
p.join()

give us similar results:

start fetching... http://www.google.ru
start fetching... http://www.s-str.ru
http://www.google.ru : 200
start fetching... http://www.vk.com
http://www.s-str.ru : 200
start fetching... http://www.yandex.ru
http://www.yandex.ru : 200
start fetching... http://www.xxx.com
http://www.vk.com : 200
http://www.xxx.com : 200

Can anyone explain the meaning of wait_available() method? And possible cases of it’s usage.

=======update========
I already monkey pathched it, it works correctly, all I want to know – is the difference between theese two code snippets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:26:17+00:00Added an answer on June 16, 2026 at 12:26 am

    Working with gevent you need to patch standard module before.

    >>> import gevent.monkey
    >>> gevent.monkey.patch_all()
    >>> ...
    >>> p = gevent.spawn(producer)
    >>> p.join()
    start fetching... http://www.google.ru
    start fetching... http://www.s-str.ru
    http://www.google.ru : 200
    start fetching... http://www.vk.com
    http://www.vk.com : 200
    start fetching... http://www.yandex.ru
    http://www.yandex.ru : 200
    start fetching... http://www.xxx.com
    http://www.xxx.com : 200
    http://www.s-str.ru : 200
    

    You can see, that pool.wait_available() works predictable.

    Update

    Pool works the same way only for spawn function (it will wait for available “slot” in pool). If you need to provide other functionality based on Pool state (logging, tracing, monitoring) – you definitely will use functions like wait_available, free_count etc. If you only need to spawn new green thread – you can rely on Pool implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been doing some reading into designing template code have a question about it.
Look at the code: template <class x> struct Foo { int getX(x *p) {
I have a simple question about sending a file (XML file) from my webapp
This question is about Blogger Template manipulation . People developing/changing or manipulating Blogger templates
I have a question about Java style. I've been programming Java for years, but
I have a question about the way Facebook limits your api calls. Toward the
This question may look stupid but that's how people learn :).I learned C++ where
I'm working on making an ASCII based game, and everywhere I look people are
I would like to look up the database table for people whose registered date
In regards to action heplers, routes, etc... I look forward to answers from people

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.