首页 文章

使用命名管道连接到LibreOffice

提问于
浏览
3

我可以很好地连接套接字,但我听说当一切都是本地的时候使用管道会更快,所以我想尝试一下,但我无法获得连接 .

我和Libre一起开始

> soffice --headless --invisible --norestore --nodefault --nolockcheck --nofirstwizard --accept='pipe,name=ooo_pipe;urp;'

最简单的python脚本应该可以工作,但不是

import uno
from com.sun.star.connection import NoConnectException

pipe = 'ooo_pipe'
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
context = resolver.resolve("uno:pipe,name=%s;urp;StarOffice.ComponentContext" % pipe)

1 回答

  • 4

    到目前为止我已经使用了套接字模式 . 刚刚在我的机器上通过cmd测试了管道:

    /usr/lib/openoffice/program/soffice.bin -accept='pipe,name=foo;urp;StarOffice.ServiceManager' -nologo -headless -nofirststartwizard -invisible
    
    $ lsof -c soffice|egrep "pipe|foo"
    soffice.b 6698 user    3r  FIFO                0,8      0t0 15766935 pipe
    soffice.b 6698 user    4w  FIFO                0,8      0t0 15766935 pipe
    soffice.b 6698 user   15u  unix 0xffff88009773ed00      0t0 15767001 /tmp/OSL_PIPE_1000_foo
    

    lsof显示有一个命名的socket foo,它可以在Python中获得连接 . 在实验开始时,有时候没有生成foo,因此引发了com.sun.star.connection.NoConnectException . 但在那之后我不能重复这个错误 .

    我们已经在 生产环境 中使用了插座模式无头门槛数年,并且它非常稳定和快速 . 看来这里的管道模式仍然依赖于unix socket,所以我建议使用套接字模式 .

相关问题