{"id":5274,"library":"jurigged","title":"Jurigged","description":"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.","status":"active","version":"0.6.1","language":"en","source_language":"en","source_url":"https://github.com/breuleux/jurigged","tags":["hot-reloading","live-coding","development","productivity","patching","dev-tools"],"install":[{"cmd":"pip install jurigged","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Used for monitoring file system changes to trigger hot reloads.","package":"watchdog","optional":false}],"imports":[{"note":"To enable programmatic file watching, e.g., in an IPython/Jupyter session, or to explicitly start watching in a script.","symbol":"watch","correct":"import jurigged\njurigged.watch()"}],"quickstart":{"code":"import jurigged\nimport time\n\ndef greet():\n    return \"Hello, Jurigged!\"\n\ndef main():\n    jurigged.watch()\n    print(\"Watching for changes... edit this file and save!\")\n    while True:\n        print(greet())\n        time.sleep(2)\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"To use jurigged, you can either run your script with `jurigged your_script.py` from the command line, or programmatically call `jurigged.watch()` within your script. Create a file named `my_app.py` with the code above. Run it using `jurigged my_app.py`. Then, modify the `greet` function (e.g., to `return \"Hello, updated Jurigged!\"`) and save the file. You will see the output change live without restarting the script."},"warnings":[{"fix":"Changes apply to the next execution of the function. For critical debugging, a full restart might be necessary, or consider alternative debugging approaches.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully manage changes to class structure, especially `__init__` and attribute definitions, during live updates. For substantial structural changes, a full application restart is recommended.","message":"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.","severity":"breaking","affected_versions":"All versions"},{"fix":"Avoid making live changes to decorator definitions or the functions they wrap in complex ways. If modifications are essential, a restart is often the safest approach.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always place your main application logic within an `if __name__ == '__main__':` block. `jurigged` will then re-execute only the diff if this guard is not touched.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If line number inconsistencies occur, restarting the application is the most reliable solution. For complex scenarios, consider simplifying the hot-reloaded code or improving test coverage to catch these issues early.","message":"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.","severity":"gotcha","affected_versions":"All versions (reported in issues up to March 2025)"},{"fix":"If file changes are not detected, try using the `--poll <INTERVAL>` flag (e.g., `jurigged --poll 1 your_script.py`). For applications requiring specific cleanup, consider implementing manual restart mechanisms or architectural patterns that tolerate abrupt code changes.","message":"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.","severity":"gotcha","affected_versions":"All versions (some `vi` issues fixed from v0.3.5)"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}