Re: python CFFI bindings integration into notmuch build/test

Subject: Re: python CFFI bindings integration into notmuch build/test

Date: Tue, 05 Nov 2019 22:47:27 +0200

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Tomi Ollila


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
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: