public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/util/futures/, lib/portage/util/futures/
Date: Mon,  3 Sep 2018 20:23:08 +0000 (UTC)	[thread overview]
Message-ID: <1536006040.b37256a524a0fbf88ffad20c9f01aaf37409ec66.zmedico@gentoo> (raw)

commit:     b37256a524a0fbf88ffad20c9f01aaf37409ec66
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep  3 20:16:37 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep  3 20:20:40 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b37256a5

compat_coroutine: CancelledError cancels coroutine's future

 lib/portage/tests/util/futures/test_compat_coroutine.py | 8 ++++++--
 lib/portage/util/futures/compat_coroutine.py            | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/portage/tests/util/futures/test_compat_coroutine.py b/lib/portage/tests/util/futures/test_compat_coroutine.py
index cbc070869..b6f75b1a2 100644
--- a/lib/portage/tests/util/futures/test_compat_coroutine.py
+++ b/lib/portage/tests/util/futures/test_compat_coroutine.py
@@ -71,6 +71,10 @@ class CompatCoroutineTestCase(TestCase):
 			loop.run_until_complete, future)
 
 	def test_cancelled_future(self):
+		"""
+		When a coroutine raises CancelledError, the coroutine's
+		future is cancelled.
+		"""
 
 		@coroutine
 		def cancelled_future_coroutine(loop=None):
@@ -81,8 +85,8 @@ class CompatCoroutineTestCase(TestCase):
 				yield future
 
 		loop = asyncio.get_event_loop()
-		self.assertRaises(asyncio.CancelledError,
-			loop.run_until_complete, cancelled_future_coroutine(loop=loop))
+		future = loop.run_until_complete(asyncio.wait([cancelled_future_coroutine()]))[0].pop()
+		self.assertTrue(future.cancelled())
 
 	def test_yield_expression_result(self):
 		@coroutine

diff --git a/lib/portage/util/futures/compat_coroutine.py b/lib/portage/util/futures/compat_coroutine.py
index 59fdc31b6..3edfa6bee 100644
--- a/lib/portage/util/futures/compat_coroutine.py
+++ b/lib/portage/util/futures/compat_coroutine.py
@@ -102,6 +102,8 @@ class _GeneratorTask(object):
 				self._generator.throw(previous.exception())
 				future = next(self._generator)
 
+		except asyncio.CancelledError:
+			self._result.cancel()
 		except _CoroutineReturnValue as e:
 			if not self._result.cancelled():
 				self._result.set_result(e.result)


             reply	other threads:[~2018-09-03 20:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 20:23 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-09-24  6:12 [gentoo-commits] proj/portage:master commit in: lib/portage/tests/util/futures/, lib/portage/util/futures/ Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536006040.b37256a524a0fbf88ffad20c9f01aaf37409ec66.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox