1 |
commit: 899d5e61010a85702e7c83506d2214ede179c964 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 1 01:34:47 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 1 01:41:03 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=899d5e61 |
7 |
|
8 |
EbuildBuildDir: cancel current tasks for CancelledError |
9 |
|
10 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
11 |
|
12 |
lib/_emerge/EbuildBuildDir.py | 46 ++++++++++++++++++++++++++++--------------- |
13 |
1 file changed, 30 insertions(+), 16 deletions(-) |
14 |
|
15 |
diff --git a/lib/_emerge/EbuildBuildDir.py b/lib/_emerge/EbuildBuildDir.py |
16 |
index 77dbff1fb..f1c49f041 100644 |
17 |
--- a/lib/_emerge/EbuildBuildDir.py |
18 |
+++ b/lib/_emerge/EbuildBuildDir.py |
19 |
@@ -6,6 +6,7 @@ from _emerge.AsynchronousLock import AsynchronousLock |
20 |
import portage |
21 |
from portage import os |
22 |
from portage.exception import PortageException |
23 |
+from portage.util.futures import asyncio |
24 |
from portage.util.futures.compat_coroutine import coroutine |
25 |
from portage.util.SlotObject import SlotObject |
26 |
|
27 |
@@ -69,22 +70,29 @@ class EbuildBuildDir(SlotObject): |
28 |
raise |
29 |
|
30 |
catdir_lock = AsynchronousLock(path=catdir, scheduler=self.scheduler) |
31 |
- yield catdir_lock.async_start() |
32 |
- yield catdir_lock.async_wait() |
33 |
- |
34 |
- self._assert_lock(catdir_lock) |
35 |
- |
36 |
+ builddir_lock = AsynchronousLock(path=dir_path, scheduler=self.scheduler) |
37 |
try: |
38 |
- portage.util.ensure_dirs(catdir, |
39 |
- gid=portage.portage_gid, |
40 |
- mode=0o70, mask=0) |
41 |
- except PortageException: |
42 |
- if not os.path.isdir(catdir): |
43 |
- raise |
44 |
+ yield catdir_lock.async_start() |
45 |
+ yield catdir_lock.async_wait() |
46 |
|
47 |
- builddir_lock = AsynchronousLock(path=dir_path, scheduler=self.scheduler) |
48 |
- yield builddir_lock.async_start() |
49 |
- yield builddir_lock.async_wait() |
50 |
+ self._assert_lock(catdir_lock) |
51 |
+ |
52 |
+ try: |
53 |
+ portage.util.ensure_dirs(catdir, |
54 |
+ gid=portage.portage_gid, |
55 |
+ mode=0o70, mask=0) |
56 |
+ except PortageException: |
57 |
+ if not os.path.isdir(catdir): |
58 |
+ raise |
59 |
+ |
60 |
+ yield builddir_lock.async_start() |
61 |
+ yield builddir_lock.async_wait() |
62 |
+ except asyncio.CancelledError: |
63 |
+ if catdir_lock.poll() is None: |
64 |
+ catdir_lock.cancel() |
65 |
+ if builddir_lock.poll() is None: |
66 |
+ builddir_lock.cancel() |
67 |
+ raise |
68 |
|
69 |
try: |
70 |
self._assert_lock(builddir_lock) |
71 |
@@ -113,8 +121,14 @@ class EbuildBuildDir(SlotObject): |
72 |
self.settings.pop('PORTAGE_BUILDDIR_LOCKED', None) |
73 |
catdir_lock = AsynchronousLock( |
74 |
path=self._catdir, scheduler=self.scheduler) |
75 |
- yield catdir_lock.async_start() |
76 |
- yield catdir_lock.async_wait() |
77 |
+ try: |
78 |
+ yield catdir_lock.async_start() |
79 |
+ yield catdir_lock.async_wait() |
80 |
+ except asyncio.CancelledError: |
81 |
+ if catdir_lock.poll() is None: |
82 |
+ catdir_lock.cancel() |
83 |
+ raise |
84 |
+ |
85 |
if catdir_lock.returncode == os.EX_OK: |
86 |
try: |
87 |
os.rmdir(self._catdir) |