Force offscreen rendering from direct python script

How can I force offscreen rendering running from python (not from pvpython)

A solution is to connect to an offscreen pvserver.