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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Reloadr-0.4.1.tar.gz | 3.8 kB | Without provenance | Details for Reloadr-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Reloadr-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for Reloadr-0.4.1-py3-none-any.whl |
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
|
Security for Reloadr 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.