Menu

Long-running script problem

Help
Sasumner
2015-09-30
2015-10-06
  • Sasumner

    Sasumner - 2015-09-30

    I have a pythonscript that can run a really long time (depending upon amount of data in the N++ editor buffer; I first noticed this when trying to run on an 11MB file); I don't have a problem with waiting patiently, but N++ itself goes into the "not responding" state (note I'm not giving it further input via mouse or keyboard) and eventually hangs.

    Is there a way around this happening for pythonscripts that can possibly run a very long time?

     
  • Dave W.

    Dave W. - 2015-09-30

    Sa, you already know the answer to that question. ;)
    Which is, "Not without doing a full-blown troubleshoot. No."
    The only way around it is, find out what's causing it and either fix it or do something totally different.

    My two cents:
    It's not the time, duration, or "long-running-ness" of the script that's the issue.
    The problem is what it's trying to do and how it's trying to do it. And maybe what it's NOT doing that it should be, like making sure temp internal data stores get built and filled properly and then deleted or cleaned out properly and re-initialized so garbage collection can be effective.
    It's either blowing out process memory, or disk space, or conflicting with another plugin, (or one you are calling), or hanging up on a network share that's not available for some reason.
    If you're doing any type of database calls, then you might be getting deadlocked there.
    Those are the most likely culprits.
    Does it call any other plugins? The problem may be in there. Maybe you can write a simple test script that just exercises that code in isolation and see if it works then.
    Is the script going into an infinite loop? (Logic issue.)
    Are you using any network folders?
    Etc.
    You may have to put in some logging/tracing statements to try and see how far it gets and what all it's done before it hits the weeds.

    You could try disabling ALL plugins, except PythonScript, of course, and the one(s) you call, if any.
    Then see if it runs ok. If so, start re-enabling the other plugins one by one til it barfs again.
    Failing that, you can also try hiding your Notepad++ folder(s) by renaming, just tacking on "XXX", just to make sure you don't lose anything, and then doing a full clean re-install.
    Lotta work, but... may be necessary. Just sayin'...
    Otherwise, you just have to analyze your logging output and see where it's blowing out.
    Cardinal rule: "If ya can't see it, ya can't fix it." ;)

    P.S. You could also try starting up Task Manager and running the script and watching the process CPU and memory allocations to see if those are indicating anything.

     

    Last edit: Dave W. 2015-09-30
  • Sasumner

    Sasumner - 2015-10-01

    DaveW,

    Thanks for taking the time to reply. 99% of me wants to withdraw the original question, citing dumbness of the poster. :)

    The remaining 1% just wants to rephrase: Very long running pythonscripts (bug-free) should have no problem running to completion, right? In other words, pythonscript itself somehow tells N++, "hey, down in a user script here....don't think things have hung, just be patient...."?

    The thing I was trying to do in a script, that I've thought I've run successfully before (on smaller data), involved a editor.rereplace() on odd line endings. Trying this now even on a small file fails. Even trying it interactively with the Find/Replace box in N++ itself causes N++ to stop responding and crash. Hmmm, maybe I have to rethink using N++ at all to fix bad line endings.

     
  • Dave W.

    Dave W. - 2015-10-01

    Sa,
    Haha! I know the feeling. Well, now you really got me curious. Can you post a snippet and a representative few lines of data? You can just email it to me if you want, or put it in a private Gist and send me the link. You are on the latest versions, Npp and PS, right?

     
  • Sasumner

    Sasumner - 2015-10-05

    DaveW,
    I guess I have egg all over my face. I tried my stuff with the latest version of N++ (was already at latest on PS) and everything regarding my problems above works fine. I tend to not to move to the latest N++ until the problems die down, so currently I'm a bit behind. So, I guess with the version I was running I'm looking at a "plugin issue" that I can attempt to isolate, or I can just continue with a newer N++ version.

     
  • Sasumner

    Sasumner - 2015-10-05

    DaveW,
    I guess I have egg all over my face. I tried my stuff with the latest version of N++ (was already at latest on PS) and everything regarding my problems above works fine. I tend to not to move to the latest N++ until the problems die down, so currently I'm a bit behind. So, I guess with the version I was running I'm looking at a "plugin issue" that I can attempt to isolate, or I can just continue with a newer N++ version.

     
  • Dave W.

    Dave W. - 2015-10-06

    Sa,
    Glad you got it working. Whatever it takes... ;)

     

Log in to post a comment.