[PATCH 1/2] Improve waiting for network connectivity

Martin Kolman mkolman at redhat.com
Wed Jul 10 12:30:08 UTC 2013


On Tue, 2013-07-09 at 12:01 -0700, Brian C. Lane wrote:
> On Tue, Jul 09, 2013 at 05:36:37PM +0200, Martin Kolman wrote:
> > Make only one function (called by the Network connectivity thread)
> > busy wait with shorter interval (0.1s instead 1s) and make other
> > callers wait for it to finish. The result is that only one busy
> > waiting is in progress at a time and all external callers are
> > unblocked at once either when connectivity is available or their
> > waiting period is over.
> > 
> > Signed-off-by: Martin Kolman <mkolman at redhat.com>
> > ---
> >  pyanaconda/network.py | 82 ++++++++++++++++++++++++++++++++++++---------------
> >  1 file changed, 58 insertions(+), 24 deletions(-)
> > 
> > diff --git a/pyanaconda/network.py b/pyanaconda/network.py
> > index ed8c866..6924759 100644
> > --- a/pyanaconda/network.py
> > +++ b/pyanaconda/network.py
> > @@ -30,6 +30,7 @@ import iutil
> >  import socket
> >  import os
> >  import time
> > +import threading
> >  import tempfile
> >  import simpleconfig
> >  import re
> > @@ -59,6 +60,12 @@ DEFAULT_HOSTNAME = "localhost.localdomain"
> >  HOSTNAME_PART_RE = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
> >  
> >  ifcfglog = None
> > +
> > +
> > +NETWORK_CONNECTED_CHECK_INTERVAL = 0.1  # in seconds
> 
> Should that be in constants.py?
OK, moving to constants.
> 
> > +    :type param: integer of float"""
> 
> You probably mean 'or' not 'of'
Yep, just a typo.
> 
> These look ok to me otherwise, but I'd like to see what Radek thinks.
> 
> I also wonder what else we can use Condition to clean up.
Yeah, i think there should be quite a few places where it could be used.
Generally anything that uses a fixed waiting period could be converted
to wait up to the waiting period or less (if some sort of external
notification is possible). But I'm sure there could be also other cases
where it could help clean up the code.
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches




More information about the anaconda-patches mailing list