[Piglit] [PATCH v3 1/2] framework/log: declare the state and state lock together

Dylan Baker baker.dylan.c at gmail.com
Wed Sep 30 09:57:26 PDT 2015


On Wed, Sep 23, 2015 at 02:35:37PM +0100, Thomas Wood wrote:
> Declare the state and state lock variables at the same time so that the
> same lock can be always used when accessing the state variable.

Hi Thomas, sorry it's taken me so long to get back to you on this.

I'll admit that concurrent programming is not something I'm especially
good at (Ilia and I went round and round about the locking in the log
module when I reworked it before we got it). I'm not understanding what declaring the
state outside of the logger is getting us.

I'm also confused that you don't seem to be using this in your follow on
patch.

I'm also confused, since you've changed the signature of the logger, but
I don't see where the callers are being changed to pass the state lock.

Dylan

> 
> v2: fix dummy logger
> 
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> ---
>  framework/log.py | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/framework/log.py b/framework/log.py
> index 759974a..423479f 100644
> --- a/framework/log.py
> +++ b/framework/log.py
> @@ -51,9 +51,10 @@ class BaseLog(object):
>      SUMMARY_KEYS = set([
>          'pass', 'fail', 'warn', 'crash', 'skip', 'dmesg-warn', 'dmesg-fail',
>          'dry-run', 'timeout'])
> -    _LOCK = threading.Lock()
> +    _LOCK = None
>  
> -    def __init__(self, state):
> +    def __init__(self, state, state_lock):
> +        self._LOCK = state_lock
>          self._state = state
>          self._pad = len(str(state['total']))
>  
> @@ -238,7 +239,7 @@ class VerboseLog(QuietLog):
>  
>  class DummyLog(BaseLog):
>      """ A Logger that does nothing """
> -    def __init__(self, state):
> +    def __init__(self, state, state_lock):
>          pass
>  
>      def start(self, name):
> @@ -285,7 +286,8 @@ class LogManager(object):
>              'complete': 0,
>              'running': [],
>          }
> +        self._state_lock = threading.Lock()
>  
>      def get(self):
>          """ Return a new log instance """
> -        return self._log(self._state)
> +        return self._log(self._state, self._state_lock)
> -- 
> 1.9.1
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150930/bce92fa8/attachment-0001.sig>


More information about the Piglit mailing list