python CFFI bindings integration into notmuch build/test

Tomi Ollila tomi.ollila at iki.fi
Tue Nov 5 12:47:27 PST 2019


On Sun, Nov 03 2019, David Bremner wrote:

>  
> @@ -32,10 +33,11 @@ def notmuch(maildir):
>          """
>          cfg_fname = maildir.path / 'notmuch-config'
>          cmd = ['notmuch'] + list(args)
> -        print('Invoking: {}'.format(' '.join(cmd)))
> +        env = os.environ.copy()
> +        env['NOTMUCH_CONFIG'] = str(cfg_fname)
>          proc = subprocess.run(cmd,
>                                timeout=5,
> -                              env={'NOTMUCH_CONFIG': str(cfg_fname)})
> +                              env=env)

Tried lambda (to have preexe_fn have cfg_fname in context), did not work,
nested function also seems to hold context:

alternative:

       ...
       print('Invoking: {}'.format(' '.join(cmd)))
        
       def preexec_fn(): os.environ['NOTMUCH_CONFIG'] = str(cfg_fname) 

       proc = subprocess.run(cmd, timeout=5, preexec_fn=preexec_fn)
       ...

The unix fork ... (here preexec_fn called in child) ... exec model is
superior to any other alternative ! =D


Tomi


More information about the notmuch mailing list