comparison Sphinx/source/plugins/python/multiprocessing-3.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 pydicom
2 import io
3
4 def OffloadedDicomParsing(dicom):
5 # No access to the "orthanc" library here, as we are in the slave process
6 dataset = pydicom.dcmread(io.BytesIO(dicom))
7 return str(dataset)
8
9 def OnRest(output, uri, **request):
10 # The call to "orthanc.RestApiGet()" is only possible in the master process
11 dicom = orthanc.RestApiGet('/instances/19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5/file')
12 answer = POOL.apply(OffloadedDicomParsing, args = (dicom, ))
13 output.AnswerBuffer(answer, 'text/plain')