Quick Fix: don't call a job interrupted while a rebuild reloads systemd
A rebuild restarts the shell mid-job, and the restarted shell asked systemd whether the job's unit was alive while the user manager was reloading. The failed query read as "stopped", so the chat showed "interrupted" and stopped polling, and the real result never appeared. A job now counts as dead only when systemd says its unit stopped and its worker process is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3d976b5961
commit
f35dbee430
2 files changed
+40
-4
No files matched your search
@@ -129,5 +129,19 @@ class QuickFix(unittest.TestCase):
|
||||
self.assertFalse(state['seen'])
|
||||
self.assertEqual(state['session']['messages'][-1]['status'], 'failed')
|
||||
|
||||
def test_a_failed_unit_query_is_not_a_dead_job(self):
|
||||
# During a rebuild systemctl may not answer; the job is still running.
|
||||
request = {'op': 'send', 'text': 'x', 'provider': 'claude', 'options': {}}
|
||||
with patch.object(quickfix, 'start_unit'):
|
||||
quickfix.handle(request)
|
||||
quickfix.save_state(started=0)
|
||||
failing = subprocess.CompletedProcess([], 1, '', 'Failed to connect to bus')
|
||||
with patch.object(quickfix.subprocess, 'run', return_value=failing):
|
||||
self.assertTrue(quickfix.handle({'op': 'state'})['running'])
|
||||
quickfix.save_state(pid=os.getpid())
|
||||
stopped = subprocess.CompletedProcess([], 3, 'inactive\n', '')
|
||||
with patch.object(quickfix.subprocess, 'run', return_value=stopped):
|
||||
self.assertTrue(quickfix.handle({'op': 'state'})['running']) # worker process alive
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user