From bd8a8ec721fc575208331bfc24a8866d7d262702 2012-04-14 22:21:25 From: MinRK Date: 2012-04-14 22:21:25 Subject: [PATCH] add 'received' timestamp to DB allows 'wall_time' to make sense in cases other than simple waiting AsyncResult. --- diff --git a/IPython/parallel/client/client.py b/IPython/parallel/client/client.py index cb8e55a..d92ab6b 100644 --- a/IPython/parallel/client/client.py +++ b/IPython/parallel/client/client.py @@ -1277,6 +1277,8 @@ class Client(HasTraits): md = self.metadata[msg_id] md.update(self._extract_metadata(header, parent, rcontent)) + if rec.get('received'): + md['received'] = rec['received'] md.update(iodict) if rcontent['status'] == 'ok': diff --git a/IPython/parallel/controller/hub.py b/IPython/parallel/controller/hub.py index eea28ed..c8f22dd 100644 --- a/IPython/parallel/controller/hub.py +++ b/IPython/parallel/controller/hub.py @@ -63,6 +63,7 @@ def empty_record(): 'started': None, 'completed': None, 'resubmitted': None, + 'received': None, 'result_header' : None, 'result_content' : None, 'result_buffers' : None, @@ -88,6 +89,7 @@ def init_record(msg): 'started': None, 'completed': None, 'resubmitted': None, + 'received': None, 'result_header' : None, 'result_content' : None, 'result_buffers' : None, @@ -630,6 +632,7 @@ class Hub(SessionFactory): result = { 'result_header' : rheader, 'result_content': msg['content'], + 'received': datetime.now(), 'started' : started, 'completed' : completed } @@ -732,7 +735,8 @@ class Hub(SessionFactory): 'result_content': msg['content'], 'started' : started, 'completed' : completed, - 'engine_uuid': engine_uuid + 'received' : datetime.now(), + 'engine_uuid': engine_uuid, } result['result_buffers'] = msg['buffers'] @@ -1176,11 +1180,12 @@ class Hub(SessionFactory): def _extract_record(self, rec): """decompose a TaskRecord dict into subsection of reply for get_result""" io_dict = {} - for key in 'pyin pyout pyerr stdout stderr'.split(): + for key in ('pyin', 'pyout', 'pyerr', 'stdout', 'stderr'): io_dict[key] = rec[key] content = { 'result_content': rec['result_content'], 'header': rec['header'], 'result_header' : rec['result_header'], + 'received' : rec['received'], 'io' : io_dict, } if rec['result_buffers']: diff --git a/IPython/parallel/controller/sqlitedb.py b/IPython/parallel/controller/sqlitedb.py index 7c3f159..0a85517 100644 --- a/IPython/parallel/controller/sqlitedb.py +++ b/IPython/parallel/controller/sqlitedb.py @@ -117,6 +117,7 @@ class SQLiteDB(BaseDB): 'started', 'completed', 'resubmitted', + 'received', 'result_header' , 'result_content' , 'result_buffers' , @@ -138,6 +139,7 @@ class SQLiteDB(BaseDB): 'started' : 'timestamp', 'completed' : 'timestamp', 'resubmitted' : 'timestamp', + 'received' : 'timestamp', 'result_header' : 'dict text', 'result_content' : 'dict text', 'result_buffers' : 'bufs blob', @@ -245,6 +247,7 @@ class SQLiteDB(BaseDB): started timestamp, completed timestamp, resubmitted timestamp, + received timestamp, result_header dict text, result_content dict text, result_buffers bufs blob,