Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

dcmread and FileDataset.save_as: thread safety

24 views
Skip to first unread message

Benjamin Golinvaux

unread,
Jan 27, 2025, 7:33:52 AMJan 27
to pydicom
Hello,

I am writing a multithreaded application and it seems that the documentation does not mention thread-safety.

May I assume that dcmread and FileDataset.save_as will not mutate global state and can be called from multiple threads?

I know that the GIL will probably makes this less than optimal, but I thought that maybe I would save some time if the GIL is released during the I/O transfer itself.

I read the code cursorily and there is no obvious thread-safety issues that stood out, but of course I could have overlooked many details.

Thanks in advance for any help or pointers you may have on this topic!

--Benjamin 

Darcy M

unread,
Jan 28, 2025, 10:11:50 PMJan 28
to pydicom
I believe you are right that dcmread and save_as do not mutate global state, although they can read from global settings.

I was searching for previous discussions around this and came across https://github.com/therlaup/pydicom-batch, which has a `threads` option, so you could check to see if there were any special considerations in their code.

Benjamin Golinvaux

unread,
Jan 29, 2025, 8:21:26 AMJan 29
to pydicom
Hello,
I browsed the source code of pydicom-batch and, indeed, Datasets are used in multiple threads, visibly without any particular problem.

Thank you very much for this information!

Reply all
Reply to author
Forward
0 new messages