Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem when creating multi-proceccing service which calling so-lib file #2489

Closed
thomas010 opened this issue Sep 9, 2018 · 2 comments
Closed

Comments

@thomas010
Copy link

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()

@ploxiln
Copy link
Contributor

ploxiln commented Sep 9, 2018

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.

@bdarnell
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants