Jurigged
Jurigged is a Python library that enables live code updating, also known as hot reloading. It intelligently patches new functions and methods into a running script, ensuring that existing instances of classes are simultaneously updated with the new behavior. When a module is modified, only the changed lines are re-executed, preserving program state. The current version is 0.6.1, released in May 2025, and the project appears to be actively maintained.
Warnings
- gotcha Functions that are currently executing or are part of an active generator/async function will continue to run with their original code. Only subsequent invocations will reflect the changes. Breakpoints on the stack cannot be changed.
- breaking Changing class initializers (`__init__`) or attribute names can lead to broken objects. Jurigged updates methods on existing instances but does not re-run `__init__` or rename attributes, potentially causing inconsistencies between new methods and old data.
- gotcha Updating code for decorators or closures may not work reliably. Decorators that inspect or modify function code might not update properly, potentially leading to unexpected behavior or stale logic.
- gotcha Changing top-level module code (outside of `if __name__ == '__main__':`) can cause the `jurigged` watcher thread to stop, preventing further hot reloads. This is particularly problematic if the top-level code includes long-running loops.
- gotcha Line numbers in patched code can sometimes diverge, leading to incorrect line numbers in stack traces, debugger breakpoints drifting, and unexpected behavior. This issue is more prevalent with complex functions, nested functions, or altered decorator calls.
- gotcha File watching mechanisms can be inconsistent. Specifically, `watchdog` on Windows may watch directories rather than individual files, and some editors (like `vi` saving to temporary swap files) can cause issues. There are also no direct hooks for cleanup on hot reload, which can complicate state management for applications like web servers that manage connections.
Install
-
pip install jurigged
Imports
- watch
import jurigged jurigged.watch()
Quickstart
import jurigged
import time
def greet():
return "Hello, Jurigged!"
def main():
jurigged.watch()
print("Watching for changes... edit this file and save!")
while True:
print(greet())
time.sleep(2)
if __name__ == '__main__':
main()