{"id":241740,"date":"2014-10-29T14:04:03","date_gmt":"2014-10-29T10:04:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=241740"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=241740","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441 \u043d\u0430 Python + AMQP<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u042f \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u043f\u0438\u0448\u0443 \u043d\u0430 Python. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 RabbitMQ. \u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c (\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c\u0438) \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440. \u0422\u0443\u0442 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b: \u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u0443\u0441\u043e\u0447\u043a\u0435 API \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421\u0430\u043c API \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 tornado, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c \u0431\u044b\u043b\u0430 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u0437 API. \u0412\u0441\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043f\u0443\u043b\u0435 \u0442\u0440\u0435\u0434\u043e\u0432. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u044f \u0440\u0435\u0448\u0438\u043b, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441(\u044b) \u00abworker\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0431\u0440\u0430\u043b \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0417\u0430\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u00abworker\u00bb \u0431\u044b\u043b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442, \u0438 \u0434\u0435\u043b\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043e\u0434\u043d\u0443 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u043a\u0430\u0436\u0435\u043c, \u0432\u044b\u0431\u0440\u0430\u043b \u0438\u0437 \u0431\u0430\u0437\u044b \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c, \u043e\u0442\u0432\u0435\u0442\u0438\u043b, \u0432\u0437\u044f\u043b \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0421\u0430\u043c\u0438\u0445 \u00abworker\u00bb\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u0434\u0430 AMQP \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0443\u0436\u0435 \u0432 \u0440\u043e\u043b\u0438 \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044f IPC.<\/p>\n<p>  \u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0440\u043e\u0441 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0440\u0443\u0442\u0438\u043d\u0443 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 AMQP \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043d\u0430\u0437\u0430\u0434, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0438\u0445 gzip\u043e\u043c, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e. \u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f <a href=\"https:\/\/github.com\/mosquito\/crew\">crew<\/a>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0433\u043e, \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 tornado \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u044b\u0445 \u00abworker\u00bb \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/mosquito\/crew\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 github<\/a>, \u0430 \u0442\u043e, \u043e \u0447\u0435\u043c \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435, \u0441\u043e\u0431\u0440\u0430\u043d\u043e <a href=\"https:\/\/github.com\/mosquito\/crew\/tree\/master\/example\">\u0432 \u043f\u0430\u043f\u043a\u0435 example<\/a>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u044d\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c RabbitMQ. \u041a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443. \u0421\u043a\u0430\u0436\u0443 \u043b\u0438\u0448\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0430 \u0442\u043e\u0439-\u0436\u0435 \u0443\u0431\u0443\u043d\u0442\u0435 \u043e\u043d \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0423 \u043c\u0435\u043d\u044f \u043d\u0430 \u043c\u0430\u043a\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c LaunchRocket, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0440\u0430\u043b \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0447\u0442\u043e \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 homebrew \u0438 \u0432\u044b\u0432\u0435\u043b \u0432 GUI:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/759\/c16\/819\/759c16819dc240848d8fbb70a4829731.jpg\" alt=\"LaunchRocket\"\/><\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 virtualenv \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0447\u0435\u0440\u0435\u0437 pip:<\/p>\n<pre><code class=\"bash\">mkdir -p api cd api virtualenv env source env\/bin\/activate pip install crew tornado <\/code><\/pre>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u043c\u043e\u0434\u0443\u043b\u044f \u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d tornado, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u0445\u043e\u0441\u0442\u0435 \u0441 worker\u043e\u043c \u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c. \u0410 \u043d\u0430 \u0432\u0435\u0431-\u0447\u0430\u0441\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u044e\u0442 requirements.txt, \u0433\u0434\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041a\u043e\u0434 \u044f \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/mosquito\/crew\/blob\/master\/example\/master.py\">\u0442\u0443\u0442<\/a>.<\/p>\n<h4>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434<\/h4>\n<p>  \u0421\u0430\u043c tornado \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 handlers, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f event-loop. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 api.<\/p>\n<p>  \u0424\u0430\u0439\u043b master.py:  <\/p>\n<pre><code class=\"python\"># encoding: utf-8  import tornado.ioloop import tornado.gen import tornado.web import tornado.options   class MainHandler(tornado.web.RequestHandler):     @tornado.gen.coroutine     def get(self):         # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 test c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c 100         resp = yield self.application.crew.call('test', priority=100)         self.write(&quot;{0}: {1}&quot;.format(type(resp).__name__, str(resp)))   application = tornado.web.Application(     [         ('\/', MainHandler),     ],     autoreload=True,     debug=True, )   if __name__ == &quot;__main__&quot;:     tornado.options.parse_command_line()     application.listen(8888)     tornado.ioloop.IOLoop.instance().start() <\/code><\/pre>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f coroutine \u0432 \u0442\u043e\u0440\u043d\u0430\u0434\u043e, \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0435\u0437 coroutine.<\/p>\n<p>  \u0424\u0430\u0439\u043b master.py:  <\/p>\n<pre><code class=\"python\">class MainHandler(tornado.web.RequestHandler):     def get(self):         # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 test c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c 100         self.application.crew.call('test', priority=100, callback=self._on_response)      def _on_response(resp, headers):         self.write(&quot;{0}: {1}&quot;.format(type(resp).__name__, str(resp))) <\/code><\/pre>\n<p>  \u041d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043e\u0442\u043e\u0432. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c, \u0438 \u0441\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \/, \u0442\u043e \u043d\u0435 \u0434\u043e\u0436\u0434\u0435\u043c\u0441\u044f \u043e\u0442\u0432\u0435\u0442\u0430, \u0435\u0433\u043e \u043d\u0435\u043a\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 worker:<\/p>\n<p>  \u0424\u0430\u0439\u043b worker.py:  <\/p>\n<pre><code class=\"python\"># encoding: utf-8  from crew.worker import run, context, Task  @Task('test') def long_task(req):     context.settings.counter += 1     return 'Wake up Neo.\\n'  run(     counter=0,      # This is a part of this worker context ) <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0432 \u043a\u043e\u0434\u0435, \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0430\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c <a href=\"http:\/\/habrahabr.ru\/users\/task\/\" class=\"user_link\">Task<\/a>(\u00abtest\u00bb), \u0433\u0434\u0435 test \u2014 \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438. \u0412 \u0432\u0430\u0448\u0435\u043c worker \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0432\u0443\u0445 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u00abcrew.example.test\u00bb (\u0442\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d \u0441\u0440\u0435\u0434\u0435), \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u00abtest\u00bb.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 context.settings.counter. \u042d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 worker \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 run. \u0422\u0430\u043a\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c context.headers \u2014 \u044d\u0442\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0430. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 callback-\u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 _on_response.<\/p>\n<p>  \u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u0430 \u0432\u043e\u0442 context.settings \u2014 \u043d\u0435\u0442. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e context.settings \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 worker(\u044b) \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 worker \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0438\u0445 \u043d\u0435 \u043c\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"bash\">$ python worker.py --help Usage: worker.py [options]  Options:   -h, --help            show this help message and exit   -v, --verbose         make lots of noise   --logging=LOGGING     Logging level   -H HOST, --host=HOST  RabbitMQ host   -P PORT, --port=PORT  RabbitMQ port <\/code><\/pre>\n<p>  URL \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 worker \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0436\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0435\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f c AMQP (\u0445\u043e\u0441\u0442 \u0438 \u043f\u043e\u0440\u0442) \u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0441\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<pre><code class=\"bash\">$ python master.py & python worker.py <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/files\/01a\/5d2\/2dc\/01a5d22dc1af4cf6aac26b656f9fbd50.jpg\" alt=\"image\"\/><\/p>\n<h4>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0437\u0430 \u0448\u0438\u0440\u043c\u043e\u0439?<\/h4>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 tornado-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 tornado \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f \u043a RabbitMQ, \u0441\u043e\u0437\u0434\u0430\u043b Exchange DLX \u0438 \u043d\u0430\u0447\u0430\u043b \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c DLX. \u042d\u0442\u043e Dead-Letter-Exchange \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0432\u0437\u044f\u043b \u043d\u0438 \u043e\u0434\u0438\u043d worker \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 timeout. \u0422\u0430\u043a\u0436\u0435 \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b \u043e\u0442 worker\u043e\u0432.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 worker \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0443\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c Task \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u0441\u044f \u043d\u0430 \u043d\u0438\u0445. \u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0440\u043a\u0435\u0440 main-loop \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044f \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041f\u043e\u0441\u043b\u0435 return \u0438\u0437 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0438 \u0441\u0442\u0430\u0432\u0438\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 tornado-\u0441\u0435\u0440\u0432\u0435\u0440 c\u0442\u0430\u0432\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u0432\u043e\u0435\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442. \u0415\u0441\u043b\u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u0432\u043e\u0440\u043a\u0435\u0440 \u043d\u0435 \u0432\u0437\u044f\u043b \u0437\u0430\u0434\u0430\u0447\u0443, \u0442\u043e\u0433\u0434\u0430 RabbitMQ \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 exchange DLX \u0438 tornado-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0441\u0442\u0435\u043a \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u043f\u0440\u0435\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h4>\u0417\u0430\u0432\u0438\u0441\u0448\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430<\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0432\u0438\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0435\u0431-\u043c\u0435\u0442\u043e\u0434 \u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 worker.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b master.py \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"python\">class FastHandler(tornado.web.RequestHandler):     @tornado.gen.coroutine     def get(self):         try:             resp = yield self.application.crew.call(                 'dead', persistent=False, priority=255, expiration=3,             )             self.write(&quot;{0}: {1}&quot;.format(type(resp).__name__, str(resp)))         except TimeoutError:             self.write('Timeout')         except ExpirationError:             self.write('All workers are gone') <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u043e\u0432:<\/p>\n<pre><code class=\"python\">application = tornado.web.Application(     [         (r&quot;\/&quot;, MainHandler),         (r&quot;\/stat&quot;, StatHandler),     ],     autoreload=True,     debug=True, ) <\/code><\/pre>\n<p>  \u0410 \u0432 worker.py:  <\/p>\n<pre><code class=\"python\">@Task('dead') def infinite_loop_task(req):     while True:         pass <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u0439\u0434\u0435\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0437\u0430 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b (\u0441\u0447\u0438\u0442\u0430\u044f \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438), main-loop \u0432 \u0432\u043e\u0440\u043a\u0435\u0440\u0435 \u043f\u043e\u0448\u043b\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 SystemExit. \u0418 \u0434\u0430, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<h4>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442<\/h4>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u043e\u0442\u0432\u0435\u0442\u0430\u043c \u043d\u0430\u0448\u0435\u0433\u043e worker.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b master.py \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 handler:<\/p>\n<pre><code class=\"python\">class StatHandler(tornado.web.RequestHandler):      @tornado.gen.coroutine     def get(self):         resp = yield self.application.crew.call('stat', persistent=False, priority=0)         self.write(&quot;{0}: {1}&quot;.format(type(resp).__name__, str(resp))) <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"python\">application = tornado.web.Application(     [         (r&quot;\/&quot;, MainHandler),         (r&quot;\/fast&quot;, FastHandler),         (r&quot;\/stat&quot;, StatHandler),     ],     autoreload=True,     debug=True, ) <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 handler \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043b worker.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u0430 \u0437\u0430\u0434\u0430\u0447\u0430.<\/p>\n<p>  \u0412 \u0444\u0430\u0439\u043b worker.py \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n<pre><code class=\"python\">@Task('stat') def get_counter(req):     context.settings.counter += 1     return 'I\\'m worker &quot;%s&quot;. And I serve %s tasks' % (context.settings.uuid, context.settings.counter) <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443, \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 worker\u043e\u043c.<\/p>\n<h4>PubSub \u0438 Long polling<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0430\u0440\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041e\u0434\u0438\u043d \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0441\u0435\u0442\u044c \u0438 \u0436\u0434\u0430\u0442\u044c, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c POST \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0445 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c.<\/p>\n<p>  master.py:<\/p>\n<pre><code class=\"python\">class LongPoolingHandler(tornado.web.RequestHandler):     LISTENERS = []      @tornado.web.asynchronous     def get(self):         self.LISTENERS.append(self.response)      def response(self, data):         self.finish(str(data))      @classmethod     def responder(cls, data):         for cb in cls.LISTENERS:             cb(data)          cls.LISTENERS = []  class PublishHandler(tornado.web.RequestHandler):      @tornado.gen.coroutine     def post(self, *args, **kwargs):         resp = yield self.application.crew.call('publish', self.request.body)         self.finish(str(resp))  ...  application = tornado.web.Application(     [         (r&quot;\/&quot;, MainHandler),         (r&quot;\/stat&quot;, StatHandler),         (r&quot;\/fast&quot;, FastHandler),         (r'\/subscribe', LongPoolingHandler),         (r'\/publish', PublishHandler),     ],     autoreload=True,     debug=True, )  application.crew = Client() application.crew.subscribe('test', LongPoolingHandler.responder)  if __name__ == &quot;__main__&quot;:     application.crew.connect()     tornado.options.parse_command_line()     application.listen(8888)     tornado.ioloop.IOLoop.instance().start() <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 publish.<\/p>\n<p>  worker.py:<\/p>\n<pre><code class=\"python\">@Task('publish') def publish(req):     context.pubsub.publish('test', req) <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 worker, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 tornado-\u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<pre><code class=\"python\">class PublishHandler2(tornado.web.RequestHandler):      def post(self, *args, **kwargs):         self.application.crew.publish('test', self.request.body) <\/code><\/pre>\n<h4>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0439<\/h4>\n<p>  \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412 crew \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440:<\/p>\n<pre><code class=\"python\">class Multitaskhandler(tornado.web.RequestHandler):      @tornado.gen.coroutine     def get(self, *args, **kwargs):         with self.application.crew.parallel() as mc:             # mc - multiple calls             mc.call('test')             mc.call('stat')             test_result, stat_result = yield mc.result()             self.set_header('Content-Type', 'text\/plain')             self.write(&quot;Test result: {0}\\nStat result: {1}&quot;.format(test_result, stat_result)) <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0437\u0430\u0434\u0430\u0447\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 with \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439.<\/p>\n<p>  \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u041e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u0435\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 test_result \u0438 stat_result \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 Exception.<\/p>\n<h4>\u041f\u043b\u0430\u043d\u044b \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435<\/h4>\n<p>  \u041a\u043e\u0433\u0434\u0430 <a href=\"http:\/\/habrahabr.ru\/users\/eigrad\/\" class=\"user_link\">eigrad<\/a> \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0435 wsgi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e crew, \u043c\u043d\u0435 \u044d\u0442\u0430 \u0438\u0434\u0435\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0445\u043b\u044b\u043d\u0443\u0442 \u043d\u0435 \u043d\u0430 \u0432\u0430\u0448\u0435 wsgi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 wsgi-worker.<\/p>\n<p>  \u042f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0438\u0441\u0430\u043b wsgi \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u044e, \u0441 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0430\u0442\u044c. \u041d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0447\u044c, pull-request\u044b \u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u0443\u043c\u0430\u044e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c client \u0434\u043b\u044f \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0434\u043b\u044f twisted. \u041d\u043e \u043f\u043e\u043a\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0441 \u043d\u0438\u043c, \u0434\u0430 \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442.<\/p>\n<h4>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u0438<\/h4>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c RabbitMQ \u0438 AMQP. \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0434\u0435\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0430\u043c, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0437\u0440\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/241740\/\"> http:\/\/habrahabr.ru\/post\/241740\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u042f \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u043f\u0438\u0448\u0443 \u043d\u0430 Python. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 RabbitMQ. \u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c (\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c\u0438) \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440. \u0422\u0443\u0442 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b: \u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u0443\u0441\u043e\u0447\u043a\u0435 API \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421\u0430\u043c API \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 tornado, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c \u0431\u044b\u043b\u0430 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u0437 API. \u0412\u0441\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043f\u0443\u043b\u0435 \u0442\u0440\u0435\u0434\u043e\u0432. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u044f \u0440\u0435\u0448\u0438\u043b, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441(\u044b) \u00abworker\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0431\u0440\u0430\u043b \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0417\u0430\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u00abworker\u00bb \u0431\u044b\u043b \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442, \u0438 \u0434\u0435\u043b\u0430\u043b \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043e\u0434\u043d\u0443 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u043a\u0430\u0436\u0435\u043c, \u0432\u044b\u0431\u0440\u0430\u043b \u0438\u0437 \u0431\u0430\u0437\u044b \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c, \u043e\u0442\u0432\u0435\u0442\u0438\u043b, \u0432\u0437\u044f\u043b \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0421\u0430\u043c\u0438\u0445 \u00abworker\u00bb\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u0434\u0430 AMQP \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0443\u0436\u0435 \u0432 \u0440\u043e\u043b\u0438 \u043d\u0435\u043a\u043e\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044f IPC.<\/p>\n<p>  \u0421\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0440\u043e\u0441 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0440\u0443\u0442\u0438\u043d\u0443 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 AMQP \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0442\u0443\u0434\u0430 \u0438 \u043d\u0430\u0437\u0430\u0434, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0438\u0445 gzip\u043e\u043c, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e. \u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f <a href=\"https:\/\/github.com\/mosquito\/crew\">crew<\/a>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0433\u043e, \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 tornado \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u044b\u0445 \u00abworker\u00bb \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/mosquito\/crew\">\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 github<\/a>, \u0430 \u0442\u043e, \u043e \u0447\u0435\u043c \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435, \u0441\u043e\u0431\u0440\u0430\u043d\u043e <a href=\"https:\/\/github.com\/mosquito\/crew\/tree\/master\/example\">\u0432 \u043f\u0430\u043f\u043a\u0435 example<\/a>.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-241740","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/241740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=241740"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/241740\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=241740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=241740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=241740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}