Re: [PATCH] EbuildIpc.communicate: lockfile PermissionDenied retry

Zac Medico <[email protected]> Sat, 6 Nov 2021 21:58:17 -0700
Newsgroups gmane.linux.gentoo.portage.devel
Message-ID <[email protected]>
On 11/3/21 20:09, Zac Medico wrote:
> The lockfile function is expected to raise PermissionDenied if
> the (root) parent process holds the lock, so retry in this case.
> 
> Bug: https://bugs.gentoo.org/468990
> Signed-off-by: Zac Medico <[email protected]>
> ---
>   bin/ebuild-ipc.py | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
> index 4999c043a..6eaa658a2 100755
> --- a/bin/ebuild-ipc.py
> +++ b/bin/ebuild-ipc.py
> @@ -158,7 +158,16 @@ class EbuildIpc:
>           # Make locks quiet since unintended locking messages displayed on
>           # stdout could corrupt the intended output of this program.
>           portage.locks._quiet = True
> -        lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
> +        # Acquire lock with PermissionDenied retry for bug #468990.
> +        for _ in range(1000):
> +            try:
> +                lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
> +            except portage.exception.PermissionDenied:
> +                time.sleep(0.1)
> +            else:
> +                break
> +        else:
> +            raise portage.exception.PermissionDenied(self.ipc_lock_file)
>   
>           try:
>               return self._communicate(args)
> 

Withdrawn in favor of this lockfile permission race fix:

https://archives.gentoo.org/gentoo-portage-dev/message/88916062415d9f692091dfb947f1bda2
-- 
Thanks,
Zac
OpenPGP_signature (application/pgp-signature, 840 B) - not displayed