[entropy.*] drop usage of another_entropy_running(), wait_resources() or similar methods should be used

This commit is contained in:
Fabio Erculiani
2011-11-12 16:10:33 +01:00
parent 032fb24740
commit 4d343233dc
5 changed files with 8 additions and 53 deletions

View File

@@ -1767,10 +1767,14 @@ class MiscMixin:
def another_entropy_running(self):
"""
Check if another Entropy instance is running.
TODO: drop method.
@deprecated: use Entropy resources methods! This will be removed SOON.
@return: True if another Entropy instance is running, False otherwise.
@rtype: bool
"""
import warnings
warnings.warn("attention, deprecated, update your code")
acquired, locked = const_setup_entropy_pid(just_read = True)
return locked

View File

@@ -3659,16 +3659,6 @@ class Package:
def run(self, xterm_header = None):
self._error_on_not_prepared()
locked = self._entropy.another_entropy_running()
if locked:
self._entropy.output(
red(_("Another Entropy is currently running.")),
importance = 1,
level = "error",
header = darkred(" @@ ")
)
return 21
gave_up = self._entropy.wait_resources()
if gave_up:
return 20

View File

@@ -1034,16 +1034,6 @@ class System:
header = red(" @@ ")
)
locked = self._entropy.another_entropy_running()
if locked:
self._entropy.output(
red(_("Another Entropy is currently running.")),
importance = 1,
level = "error",
header = darkred(" @@ ")
)
return 4
gave_up = self._entropy.wait_resources()
if gave_up:
return 7

View File

@@ -49,18 +49,6 @@ class EntropyRepositoryTest(unittest.TestCase):
self.Client.destroy()
self.Client.shutdown()
def test_another_instance(self):
pid = os.fork()
if pid == 0:
# child
locked = self.Client.another_entropy_running()
if locked:
os._exit(1)
os._exit(0)
else:
rc = os.waitpid(pid, 0)[1]
self.assertNotEqual(rc, 0)
def test_singleton(self):
myclient = Client(installed_repo = -1)
self.assertTrue(myclient is self.Client)

View File

@@ -96,10 +96,8 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
else:
# we don't want to interleave equo or entropy services with
# sulfur. People just cannot deal with it.
locked = self._entropy.another_entropy_running()
if not locked:
locked = not entropy.tools.acquire_entropy_locks(self._entropy,
max_tries = 5)
locked = not entropy.tools.acquire_entropy_locks(
self._entropy, max_tries = 5)
self._effective_root = os.getuid() == 0
if self._effective_root:
self._privileges.drop()
@@ -1549,17 +1547,9 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
with self._privileges:
# preventive check against other instances
locked = self._entropy.another_entropy_running()
if locked or not entropy.tools.is_root():
okDialog(self.ui.main,
_("Another Entropy instance is running. Cannot process queue."))
self.progress.reset_progress()
self.switch_notebook_page('packages')
return False
self.disable_ugc = True
# acquire Entropy resources here to avoid surpises afterwards
# this might be superfluous
acquired = self._entropy.lock_resources()
if not acquired:
okDialog(self.ui.main,
@@ -2367,17 +2357,10 @@ class SulfurApplication(Controller, SulfurApplicationEventsMixin):
with self._privileges:
# preventive check against other instances
locked = self._entropy.another_entropy_running()
if locked or not entropy.tools.is_root():
okDialog(self.ui.main,
_("Another Entropy instance is running. Cannot process queue."))
self.progress.reset_progress()
self.switch_notebook_page('packages')
return False
self.disable_ugc = True
# acquire Entropy resources here to avoid surpises afterwards
# this might be superfluous
acquired = self._entropy.lock_resources()
if not acquired:
okDialog(self.ui.main,