aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-04-07 21:48:05 -0700
committerZac Medico <zmedico@gentoo.org>2020-04-07 22:29:45 -0700
commitc2ffa9413bbad9d56cbed6e1d779c204fafafc69 (patch)
treebd8222a07a9f721b9c499b07731bc1a7d34cf26b /lib/_emerge
parentRevert "SpawnProcess: cancel _main_task in _unregister (bug 711174)" (diff)
downloadportage-c2ffa9413bbad9d56cbed6e1d779c204fafafc69.tar.gz
portage-c2ffa9413bbad9d56cbed6e1d779c204fafafc69.tar.bz2
portage-c2ffa9413bbad9d56cbed6e1d779c204fafafc69.zip
Revert "_BinpkgFetcherProcess: fix async_lock event loop recursion (bug 711178)"
This reverts commit 1681309f252a4e91d7256b895a9af26ef82a9b30. Bug: https://bugs.gentoo.org/716636 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/BinpkgFetcher.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/_emerge/BinpkgFetcher.py b/lib/_emerge/BinpkgFetcher.py
index e788cb05d..640eead91 100644
--- a/lib/_emerge/BinpkgFetcher.py
+++ b/lib/_emerge/BinpkgFetcher.py
@@ -16,7 +16,6 @@ import portage
from portage import os
from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
from portage.util._pty import _create_pty_or_pipe
-from portage.util.futures import asyncio
from portage.util.futures.compat_coroutine import coroutine
if sys.hexversion >= 0x3000000:
@@ -206,7 +205,6 @@ class _BinpkgFetcherProcess(SpawnProcess):
except OSError:
pass
- @coroutine
def async_lock(self):
"""
This raises an AlreadyLocked exception if lock() is called
@@ -217,22 +215,22 @@ class _BinpkgFetcherProcess(SpawnProcess):
if self._lock_obj is not None:
raise self.AlreadyLocked((self._lock_obj,))
- async_lock = self._lock_obj = AsynchronousLock(path=self.pkg_path,
+ result = self.scheduler.create_future()
+
+ def acquired_lock(async_lock):
+ if async_lock.wait() == os.EX_OK:
+ self.locked = True
+ result.set_result(None)
+ else:
+ result.set_exception(AssertionError(
+ "AsynchronousLock failed with returncode %s"
+ % (async_lock.returncode,)))
+
+ self._lock_obj = AsynchronousLock(path=self.pkg_path,
scheduler=self.scheduler)
- try:
- yield async_lock.async_start()
- yield async_lock.async_wait()
- except asyncio.CancelledError:
- if async_lock.poll() is None:
- async_lock.cancel()
- raise
-
- if async_lock.returncode != os.EX_OK:
- raise AssertionError(
- "AsynchronousLock failed with returncode %s"
- % (async_lock.returncode,))
-
- self.locked = True
+ self._lock_obj.addExitListener(acquired_lock)
+ self._lock_obj.start()
+ return result
class AlreadyLocked(portage.exception.PortageException):
pass