Nerox Posted July 17, 2011 Share Posted July 17, 2011 (edited) In a python SOP I have a function which calls it self as long as there are point numbers left in a list (A* star pathfinding). def functionX(ptNum): ----#code to figure out which point to process next (nextPt) ----#if a point is found trigger it self ----functionX(nextPt) It works fine on a very lowres mesh but it seems to get stuck when using meshes with more points (like 400 points is ok, 1600 errors). I get this error: Event Queue dropping 127590 events. I think that it is an error due to the nested function, because functionX is called for point 1, then without 'closing' the previous, functionX is called to handle the second point, etc. It seems there is a limit of recursions which I hit and thats why Python complains. If this is true, what can I do about it? I can think of situation where functionX is 'closed' before it's called again, is that possible? Edited July 17, 2011 by Nerox Quote Link to comment Share on other sites More sharing options...
edward Posted July 18, 2011 Share Posted July 18, 2011 There's obviously a limit on recursion, but I'm not not sure is this is the source of your problem. As for the event queue dropping error, that can happen if you're doing something in your Python SOP that is triggering stuff which requires the UI to refresh. Normally, the situation goes something like this: - Your code is running which does something that causes a UI event to be queued - But the UI queue can't be active yet because your code is still running - Your code keeps looping, causing UI events to be queued - Eventually too many events are queued and they start getting dropped One way to do avoid these errors in your code is to periodically call the updateui hscript command to give the UI event queue a chance to run for a bit. However, your mileage will vary. Also, updateui is a normally fairly slow command. I think the best thing to do is to avoid doing anything in tight loops that can cause UI events to be queued. Quote Link to comment Share on other sites More sharing options...
Nerox Posted July 18, 2011 Author Share Posted July 18, 2011 There's obviously a limit on recursion, but I'm not not sure is this is the source of your problem. As for the event queue dropping error, that can happen if you're doing something in your Python SOP that is triggering stuff which requires the UI to refresh. Normally, the situation goes something like this: - Your code is running which does something that causes a UI event to be queued - But the UI queue can't be active yet because your code is still running - Your code keeps looping, causing UI events to be queued - Eventually too many events are queued and they start getting dropped One way to do avoid these errors in your code is to periodically call the updateui hscript command to give the UI event queue a chance to run for a bit. However, your mileage will vary. Also, updateui is a normally fairly slow command. I think the best thing to do is to avoid doing anything in tight loops that can cause UI events to be queued. Thank you for your input Edward, I wonder what kind of things I should think of which can cause the UI to update. Could it be that an error occurs, which causes the UI to update the info for the node, but due to the recursiveness the error message is so long that this causes the Event Queue error? Last night I came up with the idea to trigger functionX() in a while loop instead of at the end of functionX(). functionX() takes a point number as input and returns one if it found a point. What if I store this number in a global variable? The while loop will look at the variable and be triggered as long as there is a value in it. To make this work, functionX will empty this variable when it starts and only put something in it if it found a 'nextPoint'. If this is a valid method it probably won't solve the error in the code, but at least it you would get rid of the 'recursive limit' and hopefully display the error properly without a Event Queue Error. Does this make sense? Quote Link to comment Share on other sites More sharing options...
edward Posted July 19, 2011 Share Posted July 19, 2011 It's hard to say as I don't know what you're doing exactly. If you're recooking nodes, then I think events will get sent out for sure. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.