nerdneilsfield / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

collapse while run in a tornado ioloop of sub-process #177

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

import sys
if sys.version_info[0] < 3:
    readln = raw_input
else:
    readln = input

import logging

logging.root.setLevel(logging.DEBUG)
logging.root.addHandler(logging.StreamHandler())

import multiprocessing
import threading

import tornado.ioloop
import tornado.web
import PyV8

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        logging.info('MainHandler get')
        script = '''var i=0;'''
        logging.info('create engine')
        engine = PyV8.JSEngine()
        with PyV8.JSContext():
            logging.info('enter v8 >>>')
            compiled = engine.compile(script)
            logging.info('leave v8 <<<')
        print('compiled = {}'.format(compiled))
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

def start_tornado():
    def _run():
        logging.info('start_tornado >>>')
        application.listen(8888)
        tornado.ioloop.IOLoop.instance().start()
        logging.info('start_tornado <<<')
    threading.Thread(target=_run).start()

if __name__ == '__main__':
    p = multiprocessing.Pool()
    p.apply(func=start_tornado)
    while True:
        readln()

What is the expected output? What do you see instead?

collapse while entering a context

What version of the product are you using? On what operating system?
on win32. linux32, python3.3, tornado3.01

Please provide any additional information below.

Original issue reported on code.google.com by RealTan...@gmail.com on 20 May 2013 at 11:00

GoogleCodeExporter commented 9 years ago
In theory, PyV8 should cowork with tornado when you use JSLock/JSUnlock, please 
check more detail in the unit test

https://code.google.com/p/pyv8/source/browse/trunk/PyV8.py#1819

Original comment by flier...@gmail.com on 20 May 2013 at 2:23

GoogleCodeExporter commented 9 years ago
Thanks! i checked it. now i think it has nothing to do the tornado ioloop. But 
perhaps PyV8 doesn't work sometimes in subprocesses. i'll check again...

Original comment by RealTan...@gmail.com on 21 May 2013 at 2:57

GoogleCodeExporter commented 9 years ago

Original comment by flier...@gmail.com on 10 Jul 2013 at 7:20