As I’m far from a Python expert, I need your help for probably a stupid race condition problem with a Python macro in LibreOffice Calc.
In short, here’s the piece of code:
# coding: utf-8 from __future__ import unicode_literals from threading import Thread def log(): sheet = XSCRIPTCONTEXT.getDocument().getCurrentController().getActiveSheet() sheet.getCellByPosition(0, 0) def go(*args): threads =  for i in range(0, 10): thread = Thread(target = log) threads.append(thread) for thread in threads: thread.start() for thread in threads: thread.join()
When I execute the
go function, the script hangs on the
log function and LibreOffice Calc just freezes: it must be killed.
I also tried to take advantage of a mutex (
Lock) in the
log function but I got the same result.
So my question is: what’s wrong with this code?
You’ll find attached to this post a
.ods file as example: test_macro.ods
Many thanks for your help!