0

I'm using PyV8 and I get this error:

#...
  File "code\engine\window.py", line 345, in run_script
    res = self.js_context.eval(js)
error: Event queue full

I am indeed running multiple things at once. How can I get around this limitation? I haven't managed to find any mention of this anywhere... the trouble with only running on .eval() at a time is that I have javascript code calling python code which calls back into the javascript code...

Claudiu
  • 224,032
  • 165
  • 485
  • 680
  • Is it possible that you have some kind of infinite recursion from JS to Python and back? If so, you could easily run into this well before you run out of stack space/recursion limit in either interpreter. – abarnert Jun 04 '13 at 01:41
  • @abarnert: good thinking, but no, this is a limited case. It's just this: - python -> javascript -> python -> javascript. Specifically: I'm running a JS script from python which calls a `require` python function which calls `.eval` on a script loaded from disk. – Claudiu Jun 04 '13 at 01:45
  • Well, I suspect you're either going to need to post an [SSCCE](http://sscce.org), trace through the code starting in `window.py`, or run it in a debugger, because, unless this is a more common problem than I think (which it may well be…), it doesn't seem likely anyone will be able to help with just this info. – abarnert Jun 04 '13 at 01:48
  • @abarnert: I think you're right. I don't fully understand how PyV8 works yet which makes me less able to ask a good question... I'll likely figure it out in the process of asking a better question, which is fine w/ me of course! – Claudiu Jun 04 '13 at 02:00

2 Answers2

0

What I ended up doing was protecting the entry points into javascript processing (from fresh python) with a threading.Lock. The require function, already being "in JS context", bypassed this lock, whereas callbacks that went back out into Python and back into JavaScript went through the lock. This seems to have done the trick for now. I wonder if that wasn't the point of PyV8.JSLocker, but it didn't seem to work well using only that class for the lock...

Claudiu
  • 224,032
  • 165
  • 485
  • 680
  • hmm this doesn't seem to work. still with only one thing processing at a time, I'm getting the error. time for more investigation... – Claudiu Jun 04 '13 at 22:07
0

Oh boy. It's just PyV8's poor error reporting at fault. What happened is my app uses pygame, and it was posting too many pygame events (thus overflowing its queue) before dealing with them. I really wish PyV8 would show the line numbers where the error happened, in the python code called from the javascript code...

Claudiu
  • 224,032
  • 165
  • 485
  • 680