How to do inter-thread communication

Discussions about using 3rd party extension with OpenOffice.org

How to do inter-thread communication

Postby LRN » Mon Oct 07, 2019 4:19 pm

Let's say that i need to do something time-consuming. The normal way to go about it is to create a thread and make it do the work, then report back with the result.

Creating a thread is not difficult. The real question is how to communicate the result *back* from the worker thread to the main thread of my office extension. Extensions, AFAIK, do not run an event loop, so there might not even *be* a "main thread" of an extension at a given moment, just the office doing its thing. I thought that maybe i could register an XJobExecutor and then use the XAsyncJob to queue a job from the worker thread to be executed in the main thread - but it's difficult to find examples of something like this, and the SDK is almost completely silent on the subject of thread-safety.

This is compounded by the fact that i'm using Python (so i will probably need to use *processes* instead of threads (thank you, GIL!), which adds a whole new set of problems with regard to communication), and Python examples are almost non-existent (SDK has 1 (/one/) Python component example).
LibreOffice 3.2 NT 6.1.7601
LRN
 
Posts: 2
Joined: Tue May 10, 2011 10:55 am

Re: How to do inter-thread communication

Postby sasa » Mon Oct 07, 2019 5:17 pm

Hi,

you can try solution in this thread, tested in dialogs and sidebar extension:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=89503

Best
LibreOffice 6.3 on Xubuntu 18.04
sasa
 
Posts: 11
Joined: Wed Feb 08, 2017 12:54 am

Re: How to do inter-thread communication

Postby psilocybe » Thu Dec 19, 2019 5:38 pm

Hi LRN,

Take a look at my http server https://github.com/prrvchr/OAuth2OOo/blob/master/OAuth2OOo/pythonpath/oauth2/wizardserver.py
It does two things.
- Waiting for a response from the OAuth2 consent screen ...
- Response with the appropriate redirect link.
LibreOffice 5.3.3.2 - Lubuntu 16.10 - LxQt 0.11.0.3
psilocybe
 
Posts: 35
Joined: Thu Jun 15, 2017 5:33 am


Return to Extensions

Who is online

Users browsing this forum: No registered users and 2 guests