view Sphinx/source/plugins/python/multiprocessing-1.py @ 1126:28dfd8d2d082 default tip

documenting wsi 3.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Dec 2024 20:29:59 +0100
parents 6e02cd89eb6a
children
line wrap: on
line source

import math
import orthanc
import time

# CPU-intensive computation taking about 4 seconds
def SlowComputation():
    start = time.time()
    for i in range(1000):
        for j in range(30000):
            math.sqrt(float(j))
    end = time.time()
    duration = (end - start)
    return 'computation done in %.03f seconds\n' % duration

def OnRest(output, uri, **request):
    answer = SlowComputation()
    output.AnswerBuffer(answer, 'text/plain')

orthanc.RegisterRestCallback('/computation', OnRest)