1 |
This calls the existing AsynchronousLock async_unlock method |
2 |
for the build directory lock, and also handles removal of the |
3 |
category directory (with async lock/unlock). |
4 |
|
5 |
Bug: https://bugs.gentoo.org/614108 |
6 |
--- |
7 |
pym/_emerge/EbuildBuildDir.py | 43 +++++++++++++++++++++++++++++++++++++++++++ |
8 |
1 file changed, 43 insertions(+) |
9 |
|
10 |
diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py |
11 |
index 58905c2f6..da7128689 100644 |
12 |
--- a/pym/_emerge/EbuildBuildDir.py |
13 |
+++ b/pym/_emerge/EbuildBuildDir.py |
14 |
@@ -88,6 +88,9 @@ class EbuildBuildDir(SlotObject): |
15 |
if self._lock_obj is None: |
16 |
return |
17 |
|
18 |
+ # Keep this legacy implementation until all consumers have migrated |
19 |
+ # to async_unlock, since run_until_complete(self.async_unlock()) |
20 |
+ # would add unwanted event loop recursion here. |
21 |
self._lock_obj.unlock() |
22 |
self._lock_obj = None |
23 |
self.locked = False |
24 |
@@ -102,6 +105,46 @@ class EbuildBuildDir(SlotObject): |
25 |
finally: |
26 |
catdir_lock.unlock() |
27 |
|
28 |
+ def async_unlock(self): |
29 |
+ """ |
30 |
+ Release the lock asynchronously. Release notification is available |
31 |
+ via the add_done_callback method of the returned Future instance. |
32 |
+ |
33 |
+ @returns: Future, result is None |
34 |
+ """ |
35 |
+ result = self.scheduler.create_future() |
36 |
+ |
37 |
+ def builddir_unlocked(future): |
38 |
+ if future.exception() is not None: |
39 |
+ result.set_exception(future.exception()) |
40 |
+ else: |
41 |
+ self._lock_obj = None |
42 |
+ self.locked = False |
43 |
+ self.settings.pop('PORTAGE_BUILDDIR_LOCKED', None) |
44 |
+ catdir_lock = AsynchronousLock( |
45 |
+ path=self._catdir, scheduler=self.scheduler) |
46 |
+ catdir_lock.start() |
47 |
+ catdir_lock.addExitListener(catdir_locked) |
48 |
+ |
49 |
+ def catdir_locked(catdir_lock): |
50 |
+ if catdir_lock.wait() != os.EX_OK: |
51 |
+ result.set_result(None) |
52 |
+ else: |
53 |
+ try: |
54 |
+ os.rmdir(self._catdir) |
55 |
+ except OSError: |
56 |
+ pass |
57 |
+ catdir_lock.async_unlock().add_done_callback(catdir_unlocked) |
58 |
+ |
59 |
+ def catdir_unlocked(future): |
60 |
+ if future.exception() is None: |
61 |
+ result.set_result(None) |
62 |
+ else: |
63 |
+ result.set_exception(future.exception()) |
64 |
+ |
65 |
+ self._lock_obj.async_unlock().add_done_callback(builddir_unlocked) |
66 |
+ return result |
67 |
+ |
68 |
class AlreadyLocked(portage.exception.PortageException): |
69 |
pass |
70 |
|
71 |
-- |
72 |
2.13.6 |