comparison Sphinx/source/plugins/python/multiprocessing-1.py @ 702:6e02cd89eb6a

moving python samples in separate files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 09:38:15 +0200
parents
children
comparison
equal deleted inserted replaced
701:f093160dd7f4 702:6e02cd89eb6a
1 import math
2 import orthanc
3 import time
4
5 # CPU-intensive computation taking about 4 seconds
6 def SlowComputation():
7 start = time.time()
8 for i in range(1000):
9 for j in range(30000):
10 math.sqrt(float(j))
11 end = time.time()
12 duration = (end - start)
13 return 'computation done in %.03f seconds\n' % duration
14
15 def OnRest(output, uri, **request):
16 answer = SlowComputation()
17 output.AnswerBuffer(answer, 'text/plain')
18
19 orthanc.RegisterRestCallback('/computation', OnRest)