def tes(): with PyV8.JSLocker(): ctxt.enter() func = ctxt.eval( """(function(){function hello(){return "Hello world.";}return hello();})""" ) print(func()) ctxt.leave() PyV8.JSUnlocker() PyV8.JSEngine.collect()