Mercurial > hg > orthanc-book
annotate Sphinx/source/plugins/python/changes-deadlock-3.0.py @ 927:dfe96daba4f8
python in win installer
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 29 Mar 2023 11:54:58 +0200 |
parents | a589668768d7 |
children |
rev | line source |
---|---|
703
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 import orthanc |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 import threading |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 def OnChange(changeType, level, resource): |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # One can safely invoke the "orthanc" module in this function |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 orthanc.LogWarning("Hello world") |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 def _OnChange(changeType, level, resource): |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # Invoke the actual "OnChange()" function in a separate thread |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 t = threading.Timer(0, function = OnChange, args = (changeType, level, resource)) |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 t.start() |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 |
a589668768d7
moving python samples in separate files (2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 orthanc.RegisterOnChangeCallback(_OnChange) |