Hot Reloading¶
Experimental Feature
Hot reloading is an experimental feature with limited support. For reliable development workflows, use Hot Restarting instead.
Overview¶
Hot reloading updates running code without restarting the application, preserving application state. This provides faster iteration than hot restarting since only changed modules are reloaded.
Current Status¶
Hot reloading in Castella is currently limited due to the complexity of:
- Preserving widget tree state across reloads
- Updating event handlers that reference old class instances
- Managing component lifecycle during reload
For most development workflows, Hot Restarting is recommended.
Web Development¶
For web applications using PyScript/Pyodide, you can use your browser's built-in development tools:
- Use your development server's live reload feature
- The browser will refresh when files change
- This is effectively hot restarting at the browser level
Alternatives¶
Hot Restarting (Recommended)¶
Use the hot restarter for reliable code updates:
See Hot Restarting for details.
Manual Reload¶
For quick experiments, you can manually restart your application after making changes.
Future Plans¶
Full hot reloading support for Component classes is planned for future releases. This would allow:
- Updating
view()methods without restart - Preserving
Statevalues across reloads - Live style and layout adjustments
Technical Challenges¶
Implementing hot reloading in a GUI framework requires solving:
-
Class identity: When a module is reloaded, classes are recreated with new identities. Existing instances still reference old classes.
-
Event handlers: Lambda functions and method references capture the original class/instance.
-
State preservation: Transferring state from old instances to new instances requires careful introspection.
-
Widget tree: The component hierarchy must be updated while maintaining parent-child relationships.
These challenges make hot restarting the more practical choice for most development scenarios.