Make sure an exception in any iterator gets raised in the main thread

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>

Conflicts:
	compose/cli/multiplexer.py
This commit is contained in:
Aanand Prasad 2015-07-22 14:47:59 +01:00
commit 80d90a745a
2 changed files with 28 additions and 5 deletions

View file

@ -26,3 +26,20 @@ class MultiplexerTest(unittest.TestCase):
[0, 1, 2, 3, 4, 5],
sorted(list(mux.loop())),
)
def test_exception(self):
class Problem(Exception):
pass
def problematic_iterator():
yield 0
yield 2
raise Problem(":(")
mux = Multiplexer([
problematic_iterator(),
(x for x in [1, 3, 5]),
])
with self.assertRaises(Problem):
list(mux.loop())