Mercurial > hg > orthanc-book
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sphinx/source/plugins/python/multiprocessing-3.py Fri Jun 11 09:38:15 2021 +0200 @@ -0,0 +1,13 @@ +import pydicom +import io + +def OffloadedDicomParsing(dicom): + # No access to the "orthanc" library here, as we are in the slave process + dataset = pydicom.dcmread(io.BytesIO(dicom)) + return str(dataset) + +def OnRest(output, uri, **request): + # The call to "orthanc.RestApiGet()" is only possible in the master process + dicom = orthanc.RestApiGet('/instances/19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5/file') + answer = POOL.apply(OffloadedDicomParsing, args = (dicom, )) + output.AnswerBuffer(answer, 'text/plain')