Closed WojciechMigda closed 8 months ago
Wand is mostly a contextlib for MagickWand's C-API. The example script is crashing as the threads is only given a memory address to allocated & deallocate -- such that -- a SIGABRT would result when on thread frees at an address that's beeing accessed by another thread.
Try the following...
def main():
with Color('#112233') as color:
Parallel(n_jobs=4, prefer='threads')(
delayed(print_color)(ix, color)
for ix in range(16))
print(str(color))
This should work as the with context
will prevent any deallcation until after all the parallel threads join.
Also... I'm not familiar with joblib
, but there should be a way to define a mutex-lock. I would encourage a mutex on any Wand methods as ImageMagick may already be multi-thread via OpenMP, and multi-threading a multi-thread solution is bad news.
Hi,
given Ubuntu 18.04/python3.7.5 or FreeBSD 13.2/python 3.10.11,
Wand
0.6.13 and simple code below:when you run it you will randomly encounter SIGABRT.
Example error outputs are:
With
faulthandler
instrumentation (python3 -X faulthandler crash.py
) the output is as follows:Disclaimer: maybe this is not a problem with Wand itself but with the way I am using managed resources with Parallel - I will leave the judgement to Wand maintainers. Anyway, you may want to look into this.