Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] attach/detach reloadium at runtime #198

Open
Andrej730 opened this issue Jul 14, 2024 · 2 comments
Open

[Feature Request] attach/detach reloadium at runtime #198

Andrej730 opened this issue Jul 14, 2024 · 2 comments

Comments

@Andrej730
Copy link

It would be nice if it was possible to attach reloadium at runtime:

  • e.g. when you're debugging some script as usual and then you realize it would be helpful to have reloadium features now, then you would be able to load it, debug the issue and unload it and keep working

  • in my case I work on Blender (3D software that has Python API) addon and I don't start Python process - it started in some internal way by Blender. So I can't just replace py my_script.py with reloadium run my_script.py to attach reloadium and option to do it somehow at runtime would help

@dkrystki
Copy link
Contributor

Reloadium has to process files during import time so attaching it after would be too late.
I haven't done much scripting in Blender. How could Reloadium help with it?

@Andrej730
Copy link
Author

Reloadium has to process files during import time so attaching it after would be too late.

Would something like this work:

  1. some reloadium.import("module_name") or reloadium.import("module_path") to reload the module and make it reloadium compatible

Example:

import reloadium
reloadium.import("test") # module is loaded and processed by reloadium
# Here python will find that module already patched by reloadium and will just reuse it.
import test
  1. Or maybe some way to patch the importing.
import reloadium
reloadium.attach()
` `test` will be imported and patched by reloadium
import test

I haven't done much scripting in Blender. How could Reloadium help with it?

I think it would help the same way as anywhere else though Blender does have a few caveats:

  • Python is started by Blender itself so you can't really customize the startup and attach reloadium there

  • save-file-and-automatically-reload feature probably wouldn't work for Blender operators and other Blender entities because of the Python API design - in Blender when you create some kind of a method that should be available to users you create an Operator class and then register it in Blender system, during registration Blender patches the class adding bunch of stuff to make it compatible with API. So just reloading a module with that Operator class wouldn't work as it would discard all the Blender runtime patches.

  • discard current local frame - very useful feature, would save tones of times when you're restarting the Blender / operators just to understand some behaviour. It's almost as useful time-travel debugging.

  • save-file-and-automatically-reload - would still be helpful for non-Blender classes as you're still interacting a lot with usual libraries you would interact with any other Python script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants