From 78886a925cf963c68c15a36f70a104fbc6bac0ff 2019-05-28 01:45:02 From: Matthias Bussonnier Date: 2019-05-28 01:45:02 Subject: [PATCH] Merge pull request #11752 from gooverdian/fix_background_job_indexing Fixes #11603 --- diff --git a/IPython/lib/backgroundjobs.py b/IPython/lib/backgroundjobs.py index ebd70d3..31997e1 100644 --- a/IPython/lib/backgroundjobs.py +++ b/IPython/lib/backgroundjobs.py @@ -86,6 +86,7 @@ class BackgroundJobManager(object): self._s_running = BackgroundJobBase.stat_running_c self._s_completed = BackgroundJobBase.stat_completed_c self._s_dead = BackgroundJobBase.stat_dead_c + self._current_job_id = 0 @property def running(self): @@ -187,7 +188,8 @@ class BackgroundJobManager(object): if kwargs.get('daemon', False): job.daemon = True - job.num = len(self.all)+1 if self.all else 0 + job.num = self._current_job_id + self._current_job_id += 1 self.running.append(job) self.all[job.num] = job debug('Starting job # %s in a separate thread.' % job.num)