Refactor progress bars somewhat to allow file-based sessions
hoping this solves issue of Apache restart at end of upgrade
This commit is contained in:
parent
f203f2c377
commit
f46e20c119
8 changed files with 48 additions and 37 deletions
|
@ -506,14 +506,13 @@ class BatchMasterView(MasterView):
|
|||
permission_prefix = self.get_permission_prefix()
|
||||
|
||||
# showing progress requires a separate thread; start that first
|
||||
progress_key = '{}.prefill'.format(route_prefix)
|
||||
progress = SessionProgress(self.request, progress_key)
|
||||
key = '{}.prefill'.format(route_prefix)
|
||||
progress = SessionProgress(self.request, key)
|
||||
thread = Thread(target=self.prefill_thread, args=(batch.uuid, progress))
|
||||
thread.start()
|
||||
|
||||
# Send user to progress page.
|
||||
kwargs = {
|
||||
'key': progress_key,
|
||||
'cancel_url': self.get_action_url('view', batch),
|
||||
'cancel_msg': "Batch prefill was canceled.",
|
||||
}
|
||||
|
@ -522,7 +521,7 @@ class BatchMasterView(MasterView):
|
|||
if not self.request.has_perm('{}.view'.format(permission_prefix)):
|
||||
kwargs['cancel_url'] = self.request.route_url('{}.create'.format(route_prefix))
|
||||
|
||||
return self.render_progress(kwargs)
|
||||
return self.render_progress(progress, kwargs)
|
||||
|
||||
def prefill_thread(self, batch_uuid, progress):
|
||||
"""
|
||||
|
@ -601,16 +600,15 @@ class BatchMasterView(MasterView):
|
|||
|
||||
# Send user to progress page.
|
||||
kwargs = {
|
||||
'key': key,
|
||||
'cancel_url': self.get_action_url('view', batch),
|
||||
'cancel_msg': "Batch refresh was canceled.",
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: This seems hacky...it exists for (only) one specific scenario.
|
||||
if not self.request.has_perm('{}.view'.format(permission_prefix)):
|
||||
kwargs['cancel_url'] = self.request.route_url('{}.create'.format(route_prefix))
|
||||
|
||||
return self.render_progress(kwargs)
|
||||
return self.render_progress(progress, kwargs)
|
||||
|
||||
def refresh_data(self, session, batch, cognizer=None, progress=None):
|
||||
"""
|
||||
|
@ -764,12 +762,12 @@ class BatchMasterView(MasterView):
|
|||
self.request.session['batch.{}.execute_option.{}'.format(batch.batch_key, key)] = unicode(value)
|
||||
|
||||
key = '{}.execute'.format(self.model_class.__tablename__)
|
||||
kwargs['progress'] = SessionProgress(self.request, key)
|
||||
progress = SessionProgress(self.request, key)
|
||||
kwargs['progress'] = progress
|
||||
thread = Thread(target=self.execute_thread, args=(batch.uuid, self.request.user.uuid), kwargs=kwargs)
|
||||
thread.start()
|
||||
|
||||
return self.render_progress({
|
||||
'key': key,
|
||||
return self.render_progress(progress, {
|
||||
'cancel_url': self.get_action_url('view', batch),
|
||||
'cancel_msg': "Batch execution was canceled.",
|
||||
})
|
||||
|
@ -850,12 +848,12 @@ class BatchMasterView(MasterView):
|
|||
|
||||
key = '{}.execute_results'.format(self.model_class.__tablename__)
|
||||
batches = self.get_effective_data()
|
||||
kwargs['progress'] = SessionProgress(self.request, key)
|
||||
progress = SessionProgress(self.request, key)
|
||||
kwargs['progress'] = progress
|
||||
thread = Thread(target=self.execute_results_thread, args=(batches, self.request.user.uuid), kwargs=kwargs)
|
||||
thread.start()
|
||||
|
||||
return self.render_progress({
|
||||
'key': key,
|
||||
return self.render_progress(progress, {
|
||||
'cancel_url': self.get_index_url(),
|
||||
'cancel_msg': "Batch execution was canceled",
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue