Skip to main content

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.

Metadata

Release files for Reloadr 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Reloadr 0.4.1
File Size Uploaded
Reloadr-0.4.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Reloadr 0.4.1
File Interpreter ABI Platform
Reloadr-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / Reloadr-0.4.1.tar.gz

Download URL Reloadr-0.4.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
136e4bbb50afbd8e63ea21150920a6acd96dd9ed7b3357e68c02937254a5bf99
BLAKE2b-256 checksum
How to use checksums
eaa431bbae9c3e6bf4f31478d7a181c4aed2dba6486f57e250260c54994c70eb
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / Reloadr-0.4.1-py3-none-any.whl

Download URL Reloadr-0.4.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4aacb7ae8ada2385e3d054328b0bf1d11bacc3b9b899f451882729d793fe0cb6
BLAKE2b-256 checksum
How to use checksums
4cf27c35c2d55512e9fc6df2a21b8dabacd40070caa4ed510f919f8a3fc6f99c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page