On Mon, Jul 17, 2017 at 12:32 PM, Edward K. Ream <edream...@gmail.com> wrote:
*> 4. Run the test, edit, repeat* > After creating the dev node you simply run the dev script until everything works :-) The details depend on the code being developed. Otoh, we can safely assume that devs can handle problems as they arise. This last sentence hides a lot, but there seems to be nothing more to be said. We are, after all, talking about a *general *framework for code reloading... Otoh, this topic does relate to #511: reload-leo command <https://github.com/leo-editor/leo-editor/issues/511> . In this context I'd like to be as specific as possible. As a first observation, the following code crashes Leo. It's not a hard crash, but Leo does exit, *despite the try/except block*: import imp import sys import traceback import leo.core.leoGlobals as g try: # This crashes Leo, despite the try/except! imp.reload(g) except Exception: typ, val, tb = sys.exc_info() lines = traceback.format_exception(typ, val, tb) print(lines) The crash happens in c.executeScriptHelper, outside of any try/except block. Indeed, the try/except block above exists only in the exec statement in c.executeScriptHelper. It is gone by the time the actual crash happens. Without going into details, the call to imp.reload(g) has thoroughly messed up Leo's run-time environment. In particular, g.app becomes None. Imo this is *not* a real bug in c.executeScriptHelper, or leoGlobals.py or anywhere else. It just means that one dasn't reload the leoGlobals module, at least not until we have a more robust init scheme. And good luck with that. Initing the leoGlobals module, and g.app, takes place very early, but despite (or because of) that it is very tricky. This post has strayed far from the previous post, but it shows that there is no way to describe all the myriad complexities that might befall people using dev nodes. Despite that, dev nodes can be extremely useful. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.