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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Reloadr-0.4.1.tar.gz
.
File metadata
- Download URL: Reloadr-0.4.1.tar.gz
- Upload date:
- Size: 3.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 136e4bbb50afbd8e63ea21150920a6acd96dd9ed7b3357e68c02937254a5bf99 |
|
MD5 | b5601062e9863b870322c394ec4bdafe |
|
BLAKE2b-256 | eaa431bbae9c3e6bf4f31478d7a181c4aed2dba6486f57e250260c54994c70eb |
File details
Details for the file Reloadr-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: Reloadr-0.4.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aacb7ae8ada2385e3d054328b0bf1d11bacc3b9b899f451882729d793fe0cb6 |
|
MD5 | 098391b62db76914ee4754e7dc13cdc0 |
|
BLAKE2b-256 | 4cf27c35c2d55512e9fc6df2a21b8dabacd40070caa4ed510f919f8a3fc6f99c |