[PATCH] Make the Welcome spoke wait for Geolocation lookup to finish (#975193)

Martin Kolman mkolman at redhat.com
Tue Jul 9 14:30:39 UTC 2013


On Tue, 2013-07-09 at 12:54 +0200, Vratislav Podzimek wrote:
> On Mon, 2013-07-08 at 19:33 +0200, Martin Kolman wrote:
> > 
> > +def _get_location_info_instance(wait=False):
> > +    """Return instance of the location info object
> > +    and optionally wait for the Geolocation thread to finish
> > +
> > +    If there is no lookup in progress (no Geolocation refresh thread
> > +    is running), this function returns at once).
> > +
> > +    Meaning of the wait parameter:
> > +    - False or <=0: don't wait
> > +    - True : wait for default number of seconds specified by
> > +    the GEOLOC_TIMEOUT constant
> > +    - >0 : wait for a given number of seconds
> > +
> > +    :param wait: specifies if this function should wait
> > +    for the lookup to finish before returning the instance
> > +    :type wait: bool or integer or float
> > +    """
> > +    if not wait:
> > +        # just returns the instance
> > +        return location_info_instance
> > +
> > +    # check if wait is a boolean or a number
> > +    if wait is True:
> > +        # use the default waiting period
> > +        wait = constants.GEOLOC_TIMEOUT
> > +    # check if there is a refresh in progress
> > +    start_time = time.time()
> > +    refresh_condition.acquire()
> > +    if refresh_in_progress:
> > +        refresh_condition.wait(timeout=wait)
> Please add a comment above this line explaining that wait first releases
> the lock of the condition and then gets it back when finished. It's not
> obvious and not everybody have the whole Python documentation in their
> heads. :) Otherwise this looks good to me.
> 
OK, I'll fix it locally & wait a bit for any additional feedback.



More information about the anaconda-patches mailing list