Js2Py icon indicating copy to clipboard operation
Js2Py copied to clipboard

No lval found "PyJs_LONG_1_"

Open lizhaode opened this issue 5 years ago • 4 comments
trafficstars

the code is

f = js2py.eval_js(run_js)
video_url = f()

sometimes it occurred error

Exception in thread Thread-39:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/js2py/evaljs.py", line 193, in execute
    compiled = cache[hashkey]
KeyError: b'\x05\x1e:\xdf\x12M\xdf\xccB5\xb2\x0fA\x01\x9d\xf7'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/opt/pornhub-myfollow/service/VideoThread.py", line 37, in run
    f = js2py.eval_js(run_js)
  File "/usr/local/lib/python3.6/dist-packages/js2py/evaljs.py", line 115, in eval_js
    return e.eval(js)
  File "/usr/local/lib/python3.6/dist-packages/js2py/evaljs.py", line 204, in eval
    self.execute(code, use_compilation_plan=use_compilation_plan)
  File "/usr/local/lib/python3.6/dist-packages/js2py/evaljs.py", line 196, in execute
    js, '', use_compilation_plan=use_compilation_plan)
  File "/usr/local/lib/python3.6/dist-packages/js2py/translators/translator.py", line 70, in translate_js
    parsed)  # syntax tree to python code
  File "/usr/local/lib/python3.6/dist-packages/js2py/translators/translating_nodes.py", line 121, in trans
    return node(**ele)
  File "/usr/local/lib/python3.6/dist-packages/js2py/translators/translating_nodes.py", line 563, in Program
    code = inline_stack.inject_inlines(code)
  File "/usr/local/lib/python3.6/dist-packages/js2py/translators/translating_nodes.py", line 48, in inject_inlines
    source = inject_before_lval(source, lval, self.reps[lval])
  File "/usr/local/lib/python3.6/dist-packages/js2py/translators/friendly_nodes.py", line 33, in inject_before_lval
    raise RuntimeError('No lval found "%s"' % lval)
RuntimeError: No lval found "PyJs_LONG_1_"

i print which run error js code , and create a test python code like only js2py.eval_js(xxxx), it run success.

So, I think the js code is right, but I don't know why full python program run, the same js code will raise execption

lizhaode avatar Feb 17 '20 12:02 lizhaode

add more error print

Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/js2py/base.py", line 1463, in call
    return Js(self.code(*args))
  File "/usr/local/lib/python3.7/site-packages/js2py/host/jseval.py", line 17, in Eval
    py_code = translate_js(code.to_string().value, '')
  File "/usr/local/lib/python3.7/site-packages/js2py/translators/translator.py", line 70, in translate_js
    parsed)  # syntax tree to python code
  File "/usr/local/lib/python3.7/site-packages/js2py/translators/translating_nodes.py", line 121, in trans
    return node(**ele)
  File "/usr/local/lib/python3.7/site-packages/js2py/translators/translating_nodes.py", line 563, in Program
    code = inline_stack.inject_inlines(code)
  File "/usr/local/lib/python3.7/site-packages/js2py/translators/translating_nodes.py", line 48, in inject_inlines
    source = inject_before_lval(source, lval, self.reps[lval])
  File "/usr/local/lib/python3.7/site-packages/js2py/translators/friendly_nodes.py", line 33, in inject_before_lval
    raise RuntimeError('No lval found "%s"' % lval)
RuntimeError: No lval found "PyJs_LONG_0_"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/Users/henryli/pornhub-myfollow/service/VideoThread.py", line 37, in run
    f = js2py.eval_js(run_js)
  File "/usr/local/lib/python3.7/site-packages/js2py/evaljs.py", line 115, in eval_js
    return e.eval(js)
  File "/usr/local/lib/python3.7/site-packages/js2py/evaljs.py", line 204, in eval
    self.execute(code, use_compilation_plan=use_compilation_plan)
  File "/usr/local/lib/python3.7/site-packages/js2py/evaljs.py", line 199, in execute
    exec (compiled, self._context)
  File "<EvalJS snippet>", line 4, in <module>
  File "<EvalJS snippet>", line 3, in PyJs_LONG_0_
  File "/usr/local/lib/python3.7/site-packages/js2py/base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "/usr/local/lib/python3.7/site-packages/js2py/base.py", line 1469, in call
    not isinstance(e, NotImplementedError) else 'Not implemented!')
AttributeError: 'RuntimeError' object has no attribute 'message'

lizhaode avatar Feb 19 '20 03:02 lizhaode

I found when run in thread , the code run in concurrent, it will raise error

add time.sleep() to make eval_js() wait a moment, it will run success

lizhaode avatar Feb 19 '20 03:02 lizhaode

i meet it too

Traceback (most recent call last): File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\evaljs.py", line 193, in execute compiled = cache[hashkey] KeyError: b'\xc9\xe3\xda\x13\xfe1L#\xac\xf7LC\xb2\xd2\x9c\xec'

During handling of the above exception, another exception occurred: ... raise RuntimeError('No lval found "%s"' % lval) RuntimeError: No lval found "PyJs_LONG_247_"

seems it is not threadsafe?

RonaldinhoL avatar Apr 27 '21 15:04 RonaldinhoL

Traceback (most recent call last): File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\evaljs.py", line 193, in execute compiled = cache[hashkey] KeyError: b'\xc9\xe3\xda\x13\xfe1L#\xac\xf7LC\xb2\xd2\x9c\xec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "E:/project snkrs/code/Engine/apps/nike/cmds/generate_js_sensordata.py", line 103, in main rets = await asyncio.gather(*tasks) File "E:/project snkrs/code/Engine/apps/nike/cmds/generate_js_sensordata.py", line 45, in get_sensordata await init_load File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\asyncio\threads.py", line 25, in to_thread return await loop.run_in_executor(None, func_call) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\concurrent\futures\thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "E:\project snkrs\code\Engine\env\jsenv\browser.py", line 116, in execute_js_file return self.jsctx.execute(js2py.get_file_contents(path_or_file)) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\evaljs.py", line 195, in execute code = translate_js( File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\translators\translator.py", line 72, in translate_js return HEADER + translating_nodes.trans( File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\translators\translating_nodes.py", line 128, in trans return node(**ele) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\translators\translating_nodes.py", line 570, in Program code = inline_stack.inject_inlines(code) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\translators\translating_nodes.py", line 48, in inject_inlines source = inject_before_lval(source, lval, self.reps[lval]) File "C:\Users\Ronaldinho.pyenv\pyenv-win\versions\Python-3.9.4\lib\site-packages\js2py\translators\friendly_nodes.py", line 28, in inject_before_lval raise RuntimeError('To many lvals (%s)' % lval) RuntimeError: To many lvals (PyJs_anonymous_0)

RonaldinhoL avatar Apr 27 '21 15:04 RonaldinhoL