{"action":"created","issue":{"url":"https://api.github.com/repos/nsqio/pynsq/issues/137","labels_url":"https://api.github.com/repos/nsqio/pynsq/issues/137/labels{/name}","comments_url":"https://api.github.com/repos/nsqio/pynsq/issues/137/comments","events_url":"https://api.github.com/repos/nsqio/pynsq/issues/137/events","html_url":"https://github.com/nsqio/pynsq/issues/137","id":122281186,"number":137,"title":"can i use pynsq writer directly without tornado?","user":{"login":"zheng-ji","id":1414745,"avatar_url":"https://avatars.githubusercontent.com/u/1414745?v=3","gravatar_id":"","url":"https://api.github.com/users/zheng-ji","html_url":"https://github.com/zheng-ji","followers_url":"https://api.github.com/users/zheng-ji/followers","following_url":"https://api.github.com/users/zheng-ji/following{/other_user}","gists_url":"https://api.github.com/users/zheng-ji/gists{/gist_id}","starred_url":"https://api.github.com/users/zheng-ji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zheng-ji/subscriptions","organizations_url":"https://api.github.com/users/zheng-ji/orgs","repos_url":"https://api.github.com/users/zheng-ji/repos","events_url":"https://api.github.com/users/zheng-ji/events{/privacy}","received_events_url":"https://api.github.com/users/zheng-ji/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nsqio/pynsq/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-15T14:14:11Z","updated_at":"2015-12-15T20:02:17Z","closed_at":null,"body":"can i use pynsq writer to pub message directory without tornado callback\r\n\r\ni try to use like that\r\n\r\n```\r\nwriter.pub('test_topic','helloworld')\r\n```\r\n\r\nbut it failed and said no logger found 'nsq.writer'"},"comment":{"url":"https://api.github.com/repos/nsqio/pynsq/issues/comments/164879625","html_url":"https://github.com/nsqio/pynsq/issues/137#issuecomment-164879625","issue_url":"https://api.github.com/repos/nsqio/pynsq/issues/137","id":164879625,"user":{"login":"ploxiln","id":649835,"avatar_url":"https://avatars.githubusercontent.com/u/649835?v=3","gravatar_id":"","url":"https://api.github.com/users/ploxiln","html_url":"https://github.com/ploxiln","followers_url":"https://api.github.com/users/ploxiln/followers","following_url":"https://api.github.com/users/ploxiln/following{/other_user}","gists_url":"https://api.github.com/users/ploxiln/gists{/gist_id}","starred_url":"https://api.github.com/users/ploxiln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploxiln/subscriptions","organizations_url":"https://api.github.com/users/ploxiln/orgs","repos_url":"https://api.github.com/users/ploxiln/repos","events_url":"https://api.github.com/users/ploxiln/events{/privacy}","received_events_url":"https://api.github.com/users/ploxiln/received_events","type":"User","site_admin":false},"created_at":"2015-12-15T20:02:17Z","updated_at":"2015-12-15T20:02:17Z","body":"You need to initialize the python logging system to avoid that error. You can add this code to do that:\r\n\r\n```\r\nimport logging\r\nlogging.basicConfig(level=logging.INFO)\r\n```\r\n\r\nBut that just enables nsq to log an error; it needs a running tornado ioloop to work.\r\n\r\n> I don't want to use http method\r\n\r\nHTTP is the simplest and most flexible way to publish to nsq (and access a variety of APIs) from whatever application / context you have - there's an http client for every context. It's going to be way easier than forcing nsq.writer to work without a running tornado ioloop.\r\n\r\nI am able to use nsq.writer without a *long term* tornado ioloop, but this is terrible and you should not do this:\r\n\r\n```\r\nimport logging\r\nimport nsq\r\nimport tornado\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\nwriter = nsq.Writer(['127.0.0.1:4150'])\r\n\r\n@tornado.gen.coroutine\r\ndef do_pub():\r\n    yield tornado.gen.sleep(1)\r\n    writer.pub(\"test_topic\", \"hello world\")\r\n    yield tornado.gen.sleep(1)\r\n\r\ntornado.ioloop.IOLoop.instance().run_sync(do_pub)\r\nprint(\"wrote one message to nsq\")\r\ntornado.ioloop.IOLoop.instance().run_sync(do_pub)\r\nprint(\"wrote another message to nsq\")\r\n```\r\n\r\nuse http"}}