problem when creating multi-proceccing service which calling so-lib file
I can't creat multi-proceccing service with tornado in which my request handler loads shared library (so lib)。problem show infomation as following and keep staying there.
WARNING:tornado.general:child 1 (pid 38338) killed by signal 11, restarting
I have tried in two ways, but both come with the problem as described before.
sockets = tornado.netutil.bind_sockets(8890) tornado.process.fork_processes(0) server = tornado.httpserver.HTTPServer(app) server.add_sockets(sockets) tornado.ioloop.IOLoop.instance().start()
and the second
app = tornado.web.Application(handlers=[ (r"/nlu", NluHandler), ], autoreload=False, debug=False) http_server = tornado.httpserver.HTTPServer(app) http_server.bind(8890) http_server.start(2) tornado.ioloop.IOLoop.instance().start()
Signal 11 is SIGSEGV (segmentation fault - invalid memory access). This probably depends specifically on the shared library. Perhaps it does something tricky during initialization (like create its own threads) and does not deal well with fork() (or it may need a post-fork() function to be callled). It may help to re-arrange your code so you can import the shared library after the fork.
Yes, this is almost certainly a problem with the shared library; nothing to do with tornado. You may be able to work around this by delaying the import of the shared library until after the child processes have started. If you can't resolve this by reordering imports or making changes in the shared library, consider using multiple processes running in single-process mode (with a load balancer in front) instead of forking from within the application.