Skip to content

Commit

Permalink
Bound the amount of time we wait for the client thread to exit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed May 9, 2019
1 parent e454ce4 commit 9533ce7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ exclude_lines =
pragma: no cover
if __name__ == ['"]__main__['"]:
assert False
self.fail
11 changes: 8 additions & 3 deletions src/ZODB/tests/testThreadedShutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class ZODBClientThread(threading.Thread):

sleep_time = 15

def __init__(self, db, test):
threading.Thread.__init__(self)
self._exc_info = None
Expand All @@ -19,7 +21,7 @@ def run(self):
conn = self.db.open()
conn.sync()
self.event.set()
time.sleep(15)
time.sleep(self.sleep_time)

# conn.close calls self.transaction_manager.unregisterSynch(self)
# and this succeeds.
Expand Down Expand Up @@ -50,8 +52,11 @@ def check_shutdown(self):
# have different contents.
self._db.close()

# Be sure not to 'leak' the running thread.
client_thread.join()
# Be sure not to 'leak' the running thread; if it hasn't
# finished after this, something went very wrong
client_thread.join(client_thread.sleep_time + 10)
if client_thread.is_alive():
self.fail("Client thread failed to close connection")


def test_suite():
Expand Down

0 comments on commit 9533ce7

Please sign in to comment.