Skip to main content

Hot code reloading tool for Python

Project description

Reloadr

Python hot code reloading tool.

pip install reloadr

Usage

You can simply decorate your functions / classes with @autoreload and you are ready to go.

from reloadr import autoreload

@autoreload
def do_something(a, b):
    return a + b

@autoreload
class SomeThing:
    def do_stuff(self):
        pass

Advanced usage

To reload the code manually, you can use of the following:

from reloadr import reloadr

@reloadr
class SomeThing:
    def do_stuff(self):
        pass

# Manual reload
SomeThing._reload()

# Automatic reload using filesystem notifications
SomeThing._start_watch_reload()

# Automatic reload in a thread every 1 second
SomeThing._start_timer_reload(1)

Examples

Launch an example (they each contain an infinite loop), then change the source code of the decorated class or function.

git clone https://github.com/hoh/reloadr.git

python examples/01_manual_reload.py

How it works

Instead of importing your source file again, which can lead to undesired side effects, Reloadr fetches the new code of your function within the Python source file, and executes that code in the environment of your already loaded module.

This allows it to reload code that is followed by blocking instructions such as the infinite loops you can find in the examples.

To achieve this, Reloadr relies on RedBaron , an great tool for manipulating Python source code.

Future plans

This project is still in its early stages. All ideas for improvement are welcome.

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

Reloadr-0.4.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

Reloadr-0.4.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file Reloadr-0.4.0.tar.gz.

File metadata

  • Download URL: Reloadr-0.4.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.6

File hashes

Hashes for Reloadr-0.4.0.tar.gz
Algorithm Hash digest
SHA256 243ca2e916e2289c534ea10991bb11249b3122b5cb77e751caf1a0ea20473f16
MD5 885c6130038973fef10bd91d713d376c
BLAKE2b-256 25d7cc80c345d7fa7aabba6edad070b9dcdc23c20d3bd0f5fa9f1d5f75ccc670

See more details on using hashes here.

Provenance

File details

Details for the file Reloadr-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: Reloadr-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.6

File hashes

Hashes for Reloadr-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f523e438970687e802014f986ed5f030d7237ee137506ae4f2fc779c178655b
MD5 8ec2fcd4f278447c8c4adce43a5d850a
BLAKE2b-256 d8904d48176fa4d331f971b56bf0a77d19e262eccca7b66d779b7686075ad64a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page