Skip to content

Gracefully stop the JobWatcher thread in the test suite

Adam Coldrick requested to merge sotk/tests/stop-job-watcher into master

Description

The JobWatcher thread currently runs forever in the test suite. This causes problems when we remove the database used in the tests which use an SQL-based scheduler, since the watcher still attempts to use the removed database and causes lots of confusing errors in the test output (though they don't actually affect whether the tests pass).

The in-memory scheduler also causes some extraneous errors, when its internal queue unexpectedly disappears.

This MR fixes both these issues by setting watcher_keep_running to False on the data store used in the tests.

The in-memory scheduler is improved to catch the EOFError raised when the queue disappears, and then check that attribute to decide whether or not to continue attempting to watch.

The SQL scheduler is also improved to check the value of watcher_keep_running before every database interaction when polling for job changes, in order to avoid the need for a large wait between setting the attribute to False and actually removing the database in the test cleanup.

Issues addressed

Closes #256 (closed)

Edited by Adam Coldrick

Merge request reports