Comments (12)
Similar capabilities have been achieved by my modified version of reloading
Use against this code:
from reloading import reloading
import asyncio
@reloading
class mClass:
someValue = 2
@reloading
def someMethod(self):
@reloading
def someInnerMethod():
raise Exception("inner exception")
return "inside function return"
raise Exception("exception")
val = someInnerMethod()
return val
@reloading
async def someOtherMethod(self):
@reloading
async def asyncInside():
raise Exception("inner async exception")
return "async inside return"
raise Exception('async exception')
val = await asyncInside()
return val
@reloading
def runAsync(self):
loop = asyncio.get_event_loop()
val = loop.run_until_complete(self.someOtherMethod())
print("value from async func:", val)
return val
@reloading
def main():
MClass = mClass # tricky exception, need to 'step out' one exception to fix this one
print(MClass)
val = MClass.someMethod()
print("return value:", val)
val = MClass.runAsync()
print("return async value:", val)
print("success!")
main()
from reloadium.
debugpy is able to capture 'raised exception' and preserve context.
from reloadium.
@James4Ever0
I think it's a great idea.
Definitely would like that be added but have to see if it's feasible to implement.
from reloadium.
I'm trying to implement this and although feasible I stumbled on a UX/Program logic issue.
For the below example it shouldn't halt the execution since the exception will be handled at the call site (line 11).
I'm trying to figure out how to detected that the exception will be handled in the future while executing the top most frame.
I've been thinking about using some static analysis and exec function to figure out whether the exception will be handled but this seems a bit hacky and potentially very slow.
Any ideas?
from reloadium.
I use code parser too to handle such nested try...except
problems. You can check how my Hy interpreter patch works. I leave multiple command line switches for turning on/off features. Notice Hy interpreter only turns Hy code into HyTree, where I do my static analysis job. What I do to handle this "checked exception" or "exception within try block" is by scanning the entire AST twice. At first scan, I mark ranges where covered try...except
and where not. At second scan, I put another level of try...except
around those lines not covered by any try...except
. In your case, you should put breakpoints outside those areas, in which those areas may differ from my case. Notice this scan is recursive in Hy, where it shall start from lowest level statements first, then composite ones.
In addition to the scanning technique, I also create some type of exception in my patch, once raised (can be configured to raise automatically?), will not be captured by any "synthetic" try...except
code blocks till top-level. This might be applied to your case, but I'm not sure.
from reloadium.
Talking of speed, I think some filesystem watchdogs plus code stored in Redis will do. Everytime code changes, it shall retrieve latest code from Redis whenever it needs. If no changes were made (changes were reported by watchdogs), no parsing nor code retrieval will be done.
from reloadium.
@James4Ever0
Thanks for your help. I managed to implement this.
Would you like to be a beta tester?
from reloadium.
Yes I would like to.
from reloadium.
Also I think generators can be tricky to deal with (functions with "yield" keywords). I would do some experiments since I lack such experience.
from reloadium.
Yes, generators can be tricky. They are not tested that well yet.
Thanks for helping out. Send me an email at [email protected] and I'll add you to our discord channel.
from reloadium.
Email sent!
from reloadium.
Added in reloadium 0.9.7 and PyCharm plugin 0.9.2
from reloadium.
Related Issues (20)
- not support WSL HOT 3
- Not support numba HOT 1
- Reloadium appears to not support debugging on remote servers. While it works fine during local testing, it fails to update on servers. HOT 4
- Reloadium debugger shows filtered log messages in django HOT 3
- Reloadium fails to start HOT 1
- Can't start debugger on Pycharm 2023.3 EAP HOT 7
- ModuleNotFoundError: No module named 'reloadium.corium' HOT 2
- Reloadimun not reloading modified pyhton files HOT 3
- Reloadium fails to start HOT 2
- VSCode plugin roadmap HOT 1
- Reloadium profiler not displayed HOT 1
- [Feature Request] Frame Transaction
- pydevd_process_net_command.py this file frequently wrong as UnicodeDecodeError
- python 3.11 annotations unsupported. HOT 11
- Docker-compose interpreter, /opt/conda/bin/python3: No module named reloadium_launcher HOT 1
- Error when exit() in interact shell HOT 1
- Issue with Reloadium in PyCharm+WSL HOT 3
- [Feature request] Request for Feature to Modify OpenAI's BaseURL
- Hot reloading of HTML files not working with reloadium (works fine with just webpack-dev-server and python manage.py runserver) HOT 2
- reloadium plugin in pycharm with twisted libary HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reloadium.