##// 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 25 from IPython.external.decorator import decorator
26 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 42 # Classes
@@ -300,7 +312,7 b' class AsyncResult(object):'
300 312 # handle single_result AsyncResults, where ar.stamp is single object,
301 313 # not a list
302 314 end = end_key(end)
303 return (end - start).total_seconds()
315 return _total_seconds(end - start)
304 316
305 317 @property
306 318 def progress(self):
@@ -323,7 +335,7 b' class AsyncResult(object):'
323 335 stamp = self._client.metadata[msg_id]['submitted']
324 336 if stamp and stamp < submitted:
325 337 submitted = stamp
326 return (now-submitted).total_seconds()
338 return _total_seconds(now-submitted)
327 339
328 340 @property
329 341 @check_ready
@@ -334,7 +346,7 b' class AsyncResult(object):'
334 346 """
335 347 t = 0
336 348 for md in self._metadata:
337 t += (md['completed'] - md['started']).total_seconds()
349 t += _total_seconds(md['completed'] - md['started'])
338 350 return t
339 351
340 352 @property
General Comments 0
You need to be logged in to leave comments. Login now