Avoid stale data when determining active tasks

Two of the three callers of get_next_task already called _clear_dead_jobs
to update the task state before searching for active tasks.

xonsh.prompt.job._current_job did not call _clear_dead_jobs, which lead to
tasks still being displayed in the title, even though they had already
finished.

Moving the call to _clear_dead_jobs into get_next_task ensures that it
always returns correct data.
This commit is contained in:
Alexander Steffen 2019-07-13 11:01:27 +02:00
parent 8576e9c22e
commit 79780d8129
2 changed files with 24 additions and 2 deletions

23
news/get_next_task.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Avoid displaying finished tasks in title.
**Security:**
* <news item>

View file

@ -84,7 +84,6 @@ if ON_WINDOWS:
Wait for the active job to finish, to be killed by SIGINT, or to be
suspended by ctrl-z.
"""
_clear_dead_jobs()
active_task = get_next_task()
# Return when there are no foreground active task
if active_task is None:
@ -187,7 +186,6 @@ else:
Wait for the active job to finish, to be killed by SIGINT, or to be
suspended by ctrl-z.
"""
_clear_dead_jobs()
active_task = get_next_task()
# Return when there are no foreground active task
if active_task is None:
@ -233,6 +231,7 @@ def _safe_wait_for_active_job(last_task=None, backgrounded=False):
def get_next_task():
""" Get the next active task and put it on top of the queue"""
_clear_dead_jobs()
selected_task = None
for tid in tasks:
task = get_task(tid)