-
Notifications
You must be signed in to change notification settings - Fork 96
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
Justpy seems to swallow exceptions in event handlers #52
Comments
Try setting `LOGGING_LEVEL = DEBUG' in justpy.env In the new version coming out soon you will get full trace with this setting. Thank you for your kind words. Do you have any suggestions how I can promote JustPy better? |
Cool. Can't wait for the next version. I tipped Michael Kennedy of the Talk Python podcast to interview you ;-) I've been searching for a full python web solution for a long time. The regular python REST API + javascript frontend just feels cumbersome (and dirty). However if you have to use JS, than Vue.js and Quasar are excellent choices. I have used them in combination with Pyramid and FastApi (also excellent with great docs). ES6 is palatable but in the end I just don't like javascript and its humongous ecosystem. I've dabbled in GraphQL as a conduit between serverside python and frontend JS but all this shuffling data to and from the browser did not feel efficient. I'm dabbling in Anvil for the same reason (all python) but it has its limitations as well and it is not open source. As you know the community is the most important asset of any framework. Please consider creating a forum so users of JustPy can help each other. Finally what people look for in a project is some indication of its viability: frequent code updates, frequent news about the project, quick bug fixes. I know its a lot to ask, but when you grow the community other people will step up, I'm sure. Keep up the good work! |
Thank you for the very helpful input which I will take to heart. Let me just address the delete_flag question as it is relatively straight forward. When a user closes a web page, the framework automatically removes all elements on the server side that correspond to elements on the closed page. Otherwise, JustPy applications would consume too much memory and won't scale well. In some cases, an element on the server side is used in multiple pages, so when any one browser tab closes, you don't want the element on the server side to be removed. That is what the delete_flag is for. It allows a one to many relation between one element on the server side and many elements in different browser tabs. The clock example in the tutorial, https://justpy.io/tutorial/pushing_data/#clock is such a case. The clock face is the same for all users. As for non-blocking database access, perhaps this would be of interest to you: https://github.com/encode/databases |
I was aware of that library, however I'd like to use Neo4J. Their python driver is not async yet. |
You can use the run_in_executor function of the asyncio library to run a Neo4J search in a non-blocking manner: https://docs.python.org/3/library/asyncio-eventloop.html#executing-code-in-thread-or-process-pools |
Ok will try that. Really need to learn Asyncio. |
LOGGING_LEVEL = DEBUG did not work for me. Still no exceptions raised. |
Please run the following:
I get the full traceback when with the error:
Are you getting something else when you run this? |
No nothing at all. Neither running normally, nor in the debugger. my justpy.env file:
|
Yes, weird. Just to be 100% sure I ran with your justpy.env and it works. |
When running with uvicorn (see #63), which shows more logging output, and using this event handler:
I see this logging output (please the different color): Running PyCharm on MacOS with python 3.7.7. I have this on 2 (similar)machines. If I look at the source code in justpy.py line 328 I see a catchall exception handler + pass (always dangerous) and, indeed it is triggered when an exception occurs in the event handler. To me that looks like the culprit. |
Please look at line 309 in justpy.py which starts handling the exception for event handler. The line number you are referring to is for the 'after' event handler (you are right, I should change that). I am using Pycharm on windows and have no problem. I will investigate in other environments, |
Ah, I see that I jumped to conclusions: indeed, exceptions in before and after events are ignored. Because they are triggered in each request those lines were reached (in the debugger) and I thought that was the cause. But you are right, the hot spot is in lines 309-314. You are catching the exception and logging it. Then, why don't I see the exception in the log? My guess is that there is some log config error/conflict. Finally I noticed that you use logging.info(), logging.debug() etc. From what I gather from talks and articles you should be creating your own logger and then use it like logger.info() etc instead of the module level logging.info etc. Like:
This enables the user of your library to tune debugging for each library separately. |
Thanks, will review the article. |
I'd made a programming error in a button handler. However no exception appeared and the program kept running (without the intended behaviour obviously). Also in the PyCharm no exception was caught.
BTW JustPy is a godsend. Please promote it more!
The text was updated successfully, but these errors were encountered: