Starting libreoffice 5.1.4.2 in listening mode

I have been trying to start LO in listening mode so I can connect to it with a external Python macro. I've tried various 'helloworld' examples and I get errors with all of them.

Such as:

__main__.NoConnectException: Connector : couldn't connect to socket
(Success)

_main__.DisposedException: Binary URP bridge disposed during call

Googling hasn't been any help.

Could someone please show me a short example of how to do this?

Thanks, Jim