##// END OF EJS Templates
Merge pull request #1608 from minrk/ar_sugar_2.6...
Fernando Perez -
r6505:5750e2dd merge
parent child Browse files
Show More
@@ -25,6 +25,18 b' from IPython.core.display import clear_output'
25 from IPython.external.decorator import decorator
25 from IPython.external.decorator import decorator
26 from IPython.parallel import error
26 from IPython.parallel import error
27
27
28 #-----------------------------------------------------------------------------
29 # Functions
30 #-----------------------------------------------------------------------------
31
32 def _total_seconds(td):
33 """timedelta.total_seconds was added in 2.7"""
34 try:
35 # Python >= 2.7
36 return td.total_seconds()
37 except AttributeError:
38 # Python 2.6
39 return 1e-6 * (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6)
28
40
29 #-----------------------------------------------------------------------------
41 #-----------------------------------------------------------------------------
30 # Classes
42 # Classes
@@ -300,7 +312,7 b' class AsyncResult(object):'
300 # handle single_result AsyncResults, where ar.stamp is single object,
312 # handle single_result AsyncResults, where ar.stamp is single object,
301 # not a list
313 # not a list
302 end = end_key(end)
314 end = end_key(end)
303 return (end - start).total_seconds()
315 return _total_seconds(end - start)
304
316
305 @property
317 @property
306 def progress(self):
318 def progress(self):
@@ -323,7 +335,7 b' class AsyncResult(object):'
323 stamp = self._client.metadata[msg_id]['submitted']
335 stamp = self._client.metadata[msg_id]['submitted']
324 if stamp and stamp < submitted:
336 if stamp and stamp < submitted:
325 submitted = stamp
337 submitted = stamp
326 return (now-submitted).total_seconds()
338 return _total_seconds(now-submitted)
327
339
328 @property
340 @property
329 @check_ready
341 @check_ready
@@ -334,7 +346,7 b' class AsyncResult(object):'
334 """
346 """
335 t = 0
347 t = 0
336 for md in self._metadata:
348 for md in self._metadata:
337 t += (md['completed'] - md['started']).total_seconds()
349 t += _total_seconds(md['completed'] - md['started'])
338 return t
350 return t
339
351
340 @property
352 @property
General Comments 0
You need to be logged in to leave comments. Login now