How to run multiple instances of Writer simultaneously?

Jens Tröger jens.troeger at
Thu Oct 19 07:05:13 UTC 2017

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("”, local)
    context = resolver.resolve("uno:pipe,name=" + pipe + ";urp;StarOffice.ComponentContext")
    desktop = context.ServiceManager.createInstanceWithContext("", 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()
    # 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> wrote:
> Hi,
> Maybe the real question is how to close a document without forcing 
> soffice process (which is shared in your case among all open documents) 
> shutdown?
> -- 
> Best regards,
> Mike Kaganski

Jens Tröger

More information about the LibreOffice mailing list