Skip to main content

A proof-of-concept serialization, transmission and restoring python runtime

Project description



A proof-of-concept serialization, transmission and restoring python runtime.

How it works

  • You invoke teleport in your python script.
  • pyteleport collects the runtime state: globals, locals, stack.
  • pyteleport dumps the runtime into a specially designed "morph" bytecode which resumes from where teleport was invoked.
  • The bytecode is transmitted to the target environment and passed to a python interpreter there.
  • The local python runtime is terminated and simply pipes stdio from the target environment.


from flow_control import bash_teleport
from socket import gethostname
from os import getpid

def log(*args):
    print(f"[{gethostname()}/{getpid()}]", *args)

bash_teleport("ssh", "cartesius",
    "conda activate py39;",
    other_fn=("", ""))


[stealth/4258] hi
[int1.bullx/17980] bye

Note that the two outputs were produced by different processes on different machines! This is what bash_teleport does: it transmits the runtime from one python process to another.

Also works from within a stack:

def a():
    def b():
        def c():
            result = "hello"
            bash_teleport("ssh", "cartesius",
                "conda activate py39;",
                other_fn=("", ""))
            return result + " world"
        return len(c()) + float("3.5")
    return 5 * (3 + b())
assert a() == 87.5

Known limitations

This is a proof of concept. It currently works only within specific conditions and with specific cPython versions.

This does not work with:

  • non-python stacks (i.e. when native code invokes python);
  • active generators in stack;
  • for, try, if, with, and all other subframes;

More information to be added.


  • 8 July 2021 21:32 CEST a python runtime was first teleported to another process on the same machine
  • 11 July 2021 20:46 CEST a python runtime was first teleported to another machine


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyteleport-0.0.tar.gz (9.8 kB view hashes)

Uploaded source

Built Distribution

pyteleport-0.0-py3.9.egg (21.9 kB view hashes)

Uploaded 0 0

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page