Here is a patch for the background sessions C API and PL/Python support. This was previously submitted as "autonomous transactions", which proved controversial, and there have been several suggestions for a new name.
I have renamed everything, removed all the incomplete PL/pgSQL stuff, did some refinement on the PL/Python interfaces, added resource owner management so that you can preserve session handles across transactions. That allows a pg_background-like behavior implemented in a PL function. I have also added documentation, so reviewers could start there. Probably not quite all done yet, but I think it contains a lot of useful pieces that we could make into something nice.