Results 1 to 8 of 8

Thread: Does LW Python cache your script?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    995

    Does LW Python cache your script?

    Another possibly dumb Python question if I may ask your kind attention:

    Does LW's Python (particularly for Modeler) cache scripts? It's probably user error, but I'm getting some weirdness where I make a change in the text file and re-run it in Modeler from the Python button and I get the old error message and the new one won't run.

    However, if I totally quit Modeler and re-run it, then it reflects the saved changes to the Python text file. What am I doing wrong? (these are very short simple scripts as I'm learning to rewrite my LScripts in Python - so it's not bugs in a long script) -- it would be crazy if I have to quit Modeler as I debug - surely it is something I am not getting right...?

    thanks for any help!
    Last edited by sami; 01-21-2014 at 08:55 PM.

  2. #2
    Member
    Join Date
    Oct 2003
    Location
    Near Edinburgh
    Posts
    246
    Been having the same problem, run a script ,get an error, fix script without quiting modeler and it still uses the orignal version of the script. restart modeler and it uses the new version. Doesn't make debugging very easy. Fogbugz this and see if you get any response.

    Regards

    Iain

  3. #3
    That has nothing to do with Newtek, thats just the way python works. You would have to reimport the module ( your script .. ) to update it in the current python shell...
    What you are asking for is more or less edit-and-continue ( because your python shell continues to run all the time in the background, no matter how often you try to start the script )
    Newtek maybe could offer some mechanism to automatically reload some modules ...
    martin dulovits
    technical director

    www.woogieworks.com

  4. #4
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    995
    Quote Originally Posted by dulo View Post
    That has nothing to do with Newtek, thats just the way python works. You would have to reimport the module ( your script .. ) to update it in the current python shell...
    What you are asking for is more or less edit-and-continue ( because your python shell continues to run all the time in the background, no matter how often you try to start the script )
    Newtek maybe could offer some mechanism to automatically reload some modules ...
    Thanks for your reply. This is very frustrating as I have to fully quit LW everytime an error hits - but if I recall correctly - only if it gets an error. If it doesn't get an error, it seems to accept the update - which I find odd. But since I'm not intimately familiar with Python and how it handles module loading, I'm not clear on why that happens. Is there a Python command that can bypass this module caching on error?

    If not can NewTek please comment on this? And fix it if possible? Even if that fix means a button which refreshes the Python without quitting Modeler. I'm worried that launching and quitting Modeler 500 times in a day is going to cause accumulated memory leaks or give me a headache down the line - I don't want to have to reboot too while debugging...

  5. #5
    Here is a link about how to handle this situation.
    http://brannerchinese.wordpress.com/...-modifying-it/
    best martin
    martin dulovits
    technical director

    www.woogieworks.com

  6. #6
    Having it cached is very useful when working on large projects. Works the same way in Maya.

    Modo failed to do this...


    Just have a simple launcher scripts which does reload() before firing it up...
    Also make sure sys.dont_write_bytecode is True in y our case.
    http://walen.se my plugins

  7. #7
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    995
    Quote Originally Posted by dulo View Post
    Here is a link about how to handle this situation.
    http://brannerchinese.wordpress.com/...-modifying-it/
    best martin
    Thanks for the link, very helpful!

    Quote Originally Posted by walfridson View Post
    Having it cached is very useful when working on large projects. Works the same way in Maya.

    Modo failed to do this...


    Just have a simple launcher scripts which does reload() before firing it up...
    Also make sure sys.dont_write_bytecode is True in y our case.
    I'll try a launcher script while debugging, thanks for the tip!

  8. #8
    I just encountered this caching problem in Layout. So to use reload is this what's supposed to be in the code?

    Code:
    import lwsdk
    reload (lwsdk)
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •