tbodt / v8py

Write Python APIs, then call them from JavaScript using the V8 engine.
GNU Lesser General Public License v3.0
443 stars 29 forks source link

Added timeout implementation per-context level #20

Closed desertkun closed 6 years ago

desertkun commented 7 years ago

Javascript can hang python from many places!

ctx = Context(timeout=0.1)
# JavaScriptTerminated
ctx.eval("while(true);") 

# old API still works and raises JavaScriptTerminated
ctx.eval("while(true);", timeout=2) 

ctx.eval("function freeze() { while(true); }")
# JavaScriptTerminated
ctx.glob.freeze() 

ctx.eval("function Freeze() { while(true); }")
# JavaScriptTerminated
new(ctx.glob.Freeze)

Not anymore.

tbodt commented 6 years ago

I went ahead and fixed a few things so I can merge, since this has been sitting around for months. Plus it includes a fix for #22.

codecov-io commented 6 years ago

Codecov Report

Merging #20 into master will increase coverage by 10.45%. The diff coverage is 94.02%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #20       +/-   ##
===========================================
+ Coverage   69.93%   80.38%   +10.45%     
===========================================
  Files          16       16               
  Lines        1224     1341      +117     
  Branches      192        0      -192     
===========================================
+ Hits          856     1078      +222     
- Misses        240      263       +23     
+ Partials      128        0      -128
Impacted Files Coverage Δ
v8py/jsfunction.cpp 96.87% <100%> (+4.28%) :arrow_up:
v8py/jsobject.cpp 90.75% <100%> (+11.54%) :arrow_up:
v8py/v8py.cpp 89.47% <100%> (+17.91%) :arrow_up:
v8py/context.cpp 88.1% <88.88%> (+10.92%) :arrow_up:
v8py/debugger.h 0% <0%> (ø) :arrow_up:
v8py/debugger.cpp 10% <0%> (+2%) :arrow_up:
v8py/greenstack.cpp 40% <0%> (+3.33%) :arrow_up:
v8py/polyfill.h 83.33% <0%> (+8.33%) :arrow_up:
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 36a07d2...76684ba. Read the comment docs.