How to run multiple instances of Writer simultaneously?
mikekaganski at hotmail.com
Thu Oct 19 07:09:19 UTC 2017
On 10/19/2017 10:05 AM, Jens Tröger wrote:
> Hi Mike,
> That would be a good answer to have, because finding documentation on this topic is tricky. Here is how I currently handle this in Python:
> pipe = …
> p = subprocess.Popen("/…/soffice --accept='pipe,name=" + pipe + ";url;StarOffice.ServiceManager' --headless --invisible", shell=True)
> # Wait for the pipe to become available.
> local = uno.getComponentContext()
> resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver”, local)
> context = resolver.resolve("uno:pipe,name=" + pipe + ";urp;StarOffice.ComponentContext")
> desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
> # Load the document
> docfile = …
> document = desktop.loadComponentFromURL("file://" + docfile, "_blank", 0, props)
> This creates a new office process and open the Writer document and connects to it. Note the absence of the custom user installation (for performance reasons)! Once I’m done with it, then:
> document.close(True) # or if XCloseable doesn’t exist: document.dispose()
Wouldn't that be enough? Why do you need other cleanup?
Supposedly having the soffice process ready for other incoming requests
would not harm the server operation, and closing the document should
have released any document-specific resources allocated.
> # context.??
> # resolver.??
> # local.??
> The termination of the process p seems to destroy the other running soffice process. Hence using custom user installations with -env:UserInstallation=/tmp/random-dir but that just prolongs the process creation noticeably!
>> On Oct 19, 2017, at 16:48, Kaganski Mike <mikekaganski at hotmail.com> wrote:
>> Maybe the real question is how to close a document without forcing
>> soffice process (which is shared in your case among all open documents)
>> Best regards,
>> Mike Kaganski
> Jens Tröger
More information about the LibreOffice