Skip to content

Commit b22691c

Browse files
committed
Revert _part of_ 75c4d5e (re #552) to fix #660
See comments in #660 for rationale and testing. tl;dr I believe this part of the fix for #552 was erroneous and I cannot currently prove that it's necessary to fix the main #552 bug; and I can prove that it is causing #660; so, revert it is. Plus clarifying the tests that were 'fixed' by #552.
1 parent 37d7f7f commit b22691c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

invoke/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ def is_dead(self):
271271
# NOTE: it seems highly unlikely that a thread could still be
272272
# is_alive() but also have encountered an exception. But hey. Why not
273273
# be thorough?
274-
alive = self.is_alive() and (self.exc_info is None)
275-
return not alive
274+
return (not self.is_alive()) and self.exc_info is not None
276275

277276
def __repr__(self):
278277
# TODO: beef this up more

tests/concurrency.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ def catches_exceptions(self):
3232
assert isinstance(wrapper.value, AttributeError)
3333

3434
def exhibits_is_dead_flag(self):
35+
# Spin up a thread that will except internally (can't put() on a
36+
# None object)
3537
t = EHThread(target=self.worker, args=[None])
3638
t.start()
3739
t.join()
40+
# Excepted -> it's dead
3841
assert t.is_dead
42+
# Spin up a happy thread that can exit peacefully (it's not "dead",
43+
# though...maybe we should change that terminology)
3944
t = EHThread(target=self.worker, args=[Queue()])
4045
t.start()
4146
t.join()
42-
assert t.is_dead
47+
# Not dead, just uh...sleeping?
48+
assert not t.is_dead
4349

4450
class via_subclassing:
4551
def setup(self):
@@ -73,11 +79,17 @@ def catches_exceptions(self):
7379
assert isinstance(wrapper.value, AttributeError)
7480

7581
def exhibits_is_dead_flag(self):
82+
# Spin up a thread that will except internally (can't put() on a
83+
# None object)
7684
t = self.klass(queue=None)
7785
t.start()
7886
t.join()
87+
# Excepted -> it's dead
7988
assert t.is_dead
89+
# Spin up a happy thread that can exit peacefully (it's not "dead",
90+
# though...maybe we should change that terminology)
8091
t = self.klass(queue=Queue())
8192
t.start()
8293
t.join()
83-
assert t.is_dead
94+
# Not dead, just uh...sleeping?
95+
assert not t.is_dead

0 commit comments

Comments
 (0)