Mercurial > hg > orthanc-book
annotate Sphinx/source/plugins/python/multiprocessing-3.py @ 927:dfe96daba4f8
python in win installer
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 29 Mar 2023 11:54:58 +0200 |
parents | 6e02cd89eb6a |
children |
rev | line source |
---|---|
702
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 import pydicom |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 import io |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 def OffloadedDicomParsing(dicom): |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # No access to the "orthanc" library here, as we are in the slave process |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 dataset = pydicom.dcmread(io.BytesIO(dicom)) |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 return str(dataset) |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 def OnRest(output, uri, **request): |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # The call to "orthanc.RestApiGet()" is only possible in the master process |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 dicom = orthanc.RestApiGet('/instances/19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5/file') |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 answer = POOL.apply(OffloadedDicomParsing, args = (dicom, )) |
6e02cd89eb6a
moving python samples in separate files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 output.AnswerBuffer(answer, 'text/plain') |