Commit 73bca206 authored by Remi Perenon's avatar Remi Perenon

Adding delay after end of a job before supressing the status file and modifying JobPlugin behaviour

parent c535896b
......@@ -73,7 +73,17 @@ class Platform(object):
:rtype: str
'''
return os.path.join(self.package_directory(), 'Doc')
return os.path.join(self.package_directory(), 'Doc')
def jobs_launch_delay(self):
'''
Returns the delay (in seconds) for a job to launch.
This is used to determine the delay before updating the GUI and suppressing a job status file
:return: the delay (in seconds) for a job to launch
:rtype: float
'''
return 2.0
def api_path(self):
'''
......
......@@ -16,6 +16,8 @@ import collections
import cPickle
import datetime
import os
import threading
import time
from MDANSE import PLATFORM
from MDANSE.Framework.Status import Status
......@@ -47,8 +49,9 @@ class JobStatus(Status):
self.save_status()
def finish_status(self):
self.cleanup()
# Launch a thread that will wait before erasing the file
t= threading.Thread(target = self.cleanup)
t.start()
@property
def state(self):
......@@ -56,7 +59,8 @@ class JobStatus(Status):
return self._state
def cleanup(self):
# Wait before cleaning
time.sleep(PLATFORM.jobs_launch_delay())
try:
os.unlink(self._state['temporary_file'])
except:
......
......@@ -216,9 +216,12 @@ class JobControllerPanel(wx.ScrolledWindow):
event.Skip()
def msg_start_job(self,message):
self._jobsController.update()
t = threading.Thread(target=self.updateJobsController)
t.start()
def updateJobsController(self):
time.sleep(PLATFORM.jobs_launch_delay())
self._jobsController.update()
def on_display_info(self,event):
row = self._gbSizer.GetItemPosition(event.GetEventObject())[0]
......
......@@ -113,9 +113,13 @@ class JobPlugin(ComponentPlugin):
message = e.output
else:
message = None
time.sleep(1)
PUBLISHER.sendMessage("msg_start_job",message=message)
PUBLISHER.sendMessage("msg_start_job",message=message)
if message is None:
d = wx.MessageDialog(None, 'Your analysis is performing. Do you want to close ?', 'Question', wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION)
if d.ShowModal() == wx.ID_YES:
self.on_close(None)
def on_save(self, event=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment