{"action":"created","issue":{"url":"https://api.github.com/repos/nodesign/weio/issues/217","labels_url":"https://api.github.com/repos/nodesign/weio/issues/217/labels{/name}","comments_url":"https://api.github.com/repos/nodesign/weio/issues/217/comments","events_url":"https://api.github.com/repos/nodesign/weio/issues/217/events","html_url":"https://github.com/nodesign/weio/issues/217","id":72809030,"number":217,"title":"Possible Race Condition on Server Push","user":{"login":"drasko","id":149944,"avatar_url":"https://avatars.githubusercontent.com/u/149944?v=3","gravatar_id":"","url":"https://api.github.com/users/drasko","html_url":"https://github.com/drasko","followers_url":"https://api.github.com/users/drasko/followers","following_url":"https://api.github.com/users/drasko/following{/other_user}","gists_url":"https://api.github.com/users/drasko/gists{/gist_id}","starred_url":"https://api.github.com/users/drasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drasko/subscriptions","organizations_url":"https://api.github.com/users/drasko/orgs","repos_url":"https://api.github.com/users/drasko/repos","events_url":"https://api.github.com/users/drasko/events{/privacy}","received_events_url":"https://api.github.com/users/drasko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-03T13:52:56Z","updated_at":"2015-05-03T18:11:27Z","closed_at":null,"body":"For some reason, examples that use serverPush() break after some time with the error message presented below.\r\n\r\nThis example: https://github.com/nodesign/weio/blob/master/examples/analog/analogReadPotentio_JS\r\nbreaks.\r\n\r\nSo is this one: https://github.com/nodesign/weio/tree/master/examples/webApps/bgColorLEDWEB.\r\n\r\nThis makes usage of the board very unstable and should be treated in urgenence.\r\n\r\nLog:\r\n\r\nMESSAGE analogRead {'data': 765, 'pin': 25} [25] 32601802-01b7-459f-bd3b-6be518383511\r\n\r\nException in thread Thread-1:\r\n\r\nERR 0 : Exception in thread Thread-1:\r\n\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\nTraceback (most recent call last):\r\n\r\nERR 0 : Traceback (most recent call last):\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/threading.py\", line 810, in __bootstrap_inner\r\n\r\nERR 1 :   File \"/usr/lib/python2.7/threading.py\", line 810, in __bootstrap_inner\r\n\r\nerror in file :  /usr/lib/python2.7/threading.py\r\nerror in line :   810\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x111f600>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x111f600>\r\n\r\n    self.run()\r\n\r\nERR 2 :     self.run()\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 776, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 776, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/threading.py\", line 763, in run\r\n\r\nERR 3 :   File \"/usr/lib/python2.7/threading.py\", line 763, in run\r\n\r\nerror in file :  /usr/lib/python2.7/threading.py\r\nerror in line :   763\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self.__target(*self.__args, **self.__kwargs)\r\n\r\nERR 4 :     self.__target(*self.__args, **self.__kwargs)\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"./weioRunner.py\", line 344, in listenerThread\r\n\r\nERR 5 :   File \"./weioRunner.py\", line 344, in listenerThread\r\n\r\nerror in file :  ./weioRunner.py\r\nerror in line :   344\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1118b38>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1118b38>\r\n\r\n    weioRunnerGlobals.weioConnections[connUuid].send(json.dumps(result))\r\n\r\nERR 6 :     weioRunnerGlobals.weioConnections[connUuid].send(json.dumps(result))\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 763, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 763, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/site-packages/sockjs/tornado/conn.py\", line 49, in send\r\n\r\nERR 7 :   File \"/usr/lib/python2.7/site-packages/sockjs/tornado/conn.py\", line 49, in send\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/sockjs/tornado/conn.py\r\nerror in line :   49\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self.session.send_message(message, binary=binary)\r\n\r\nERR 8 :     self.session.send_message(message, binary=binary)\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 324, in send_message\r\n\r\nERR 9 :   File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 324, in send_message\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/sockjs/tornado/session.py\r\nerror in line :   324\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1119b68>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1119b68>\r\n\r\n    self.send_jsonified(proto.json_encode(bytes_to_str(msg)), stats)\r\n\r\nERR 10 :     self.send_jsonified(proto.json_encode(bytes_to_str(msg)), stats)\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 345, in send_jsonified\r\n\r\nERR 11 :   File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 345, in send_jsonified\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/sockjs/tornado/session.py\r\nerror in line :   345\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self.flush()\r\n\r\nERR 12 :     self.flush()\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 365, in flush\r\n\r\nERR 13 :   File \"/usr/lib/python2.7/site-packages/sockjs/tornado/session.py\", line 365, in flush\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/sockjs/tornado/session.py\r\nerror in line :   365\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1158878>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x1158878>\r\n\r\n    self.handler.send_pack('a[%s]' % self.send_queue)\r\n\r\nERR 14 :     self.handler.send_pack('a[%s]' % self.send_queue)\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 763, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 763, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/site-packages/sockjs/tornado/transports/xhrstreaming.py\", line 46, in send_pack\r\n\r\nERR 15 :   File \"/usr/lib/python2.7/site-packages/sockjs/tornado/transports/xhrstreaming.py\", line 46, in send_pack\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/sockjs/tornado/transports/xhrstreaming.py\r\nerror in line :   46\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self.flush(callback=self.send_complete)\r\n\r\nERR 16 :     self.flush(callback=self.send_complete)\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/site-packages/tornado/web.py\", line 705, in flush\r\n\r\nERR 17 :   File \"/usr/lib/python2.7/site-packages/tornado/web.py\", line 705, in flush\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/tornado/web.py\r\nerror in line :   705\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x111f600>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x111f600>\r\n\r\n    self.request.write(headers + chunk, callback=callback)\r\n\r\nERR 18 :     self.request.write(headers + chunk, callback=callback)\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/site-packages/tornado/httpserver.py\", line 470, in write\r\n\r\nERR 19 :   File \"/usr/lib/python2.7/site-packages/tornado/httpserver.py\", line 470, in write\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/tornado/httpserver.py\r\nerror in line :   470\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self.connection.write(chunk, callback=callback)\r\n\r\nERR 20 :     self.connection.write(chunk, callback=callback)\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/site-packages/tornado/httpserver.py\", line 234, in write\r\n\r\nERR 21 :   File \"/usr/lib/python2.7/site-packages/tornado/httpserver.py\", line 234, in write\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/tornado/httpserver.py\r\nerror in line :   234\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x110c010>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x110c010>\r\n\r\n    self.stream.write(chunk, self._on_write_complete)\r\n\r\nERR 22 :     self.stream.write(chunk, self._on_write_complete)\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\nMESSAGE analogRead {'data': 764, 'pin': 25} [25] 91200ecc-6b38-457c-97f0-54e384c9c455\r\n\r\n  File \"/usr/lib/python2.7/site-packages/tornado/iostream.py\", line 214, in write\r\n\r\nERR 23 :   File \"/usr/lib/python2.7/site-packages/tornado/iostream.py\", line 214, in write\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/tornado/iostream.py\r\nerror in line :   214\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n    self._handle_write()\r\n\r\nERR 24 :     self._handle_write()\r\n\r\nSTDOUT  CALLBACK IS NONE!\r\n\r\nCALLBACK IS NONE!\r\n\r\n  File \"/usr/lib/python2.7/site-packages/tornado/iostream.py\", line 505, in _handle_write\r\n\r\nERR 25 :   File \"/usr/lib/python2.7/site-packages/tornado/iostream.py\", line 505, in _handle_write\r\n\r\nerror in file :  /usr/lib/python2.7/site-packages/tornado/iostream.py\r\nerror in line :   505\r\nSTDOUT  GOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x115a130>\r\n\r\nGOT MSG:  <weioLib.weioRunnerGlobals.userAgentMessage instance at 0x115a130>\r\n\r\n    num_bytes = self.write_to_fd(self._write_buffer[0])\r\n\r\nERR 26 :     num_bytes = self.write_to_fd(self._write_buffer[0])\r\n\r\nSTDOUT  MESSAGE analogRead {'data': 763, 'pin': 25} [25] 3233511b-d246-4454-8b92-5e7c5089c053\r\n\r\nMESSAGE analogRead {'data': 763, 'pin': 25} [25] 3233511b-d246-4454-8b92-5e7c5089c053\r\n\r\nIndexError: deque index out of range\r\n\r\nERR 27 : IndexError: deque index out of range\r\n\r\nSTDOUT  PUSHING:  fromAdc\r\n\r\nPUSHING:  fromAdc\r\n\r\n\r\n\r\nERR 28 :\r\n"},"comment":{"url":"https://api.github.com/repos/nodesign/weio/issues/comments/98518389","html_url":"https://github.com/nodesign/weio/issues/217#issuecomment-98518389","issue_url":"https://api.github.com/repos/nodesign/weio/issues/217","id":98518389,"user":{"login":"drasko","id":149944,"avatar_url":"https://avatars.githubusercontent.com/u/149944?v=3","gravatar_id":"","url":"https://api.github.com/users/drasko","html_url":"https://github.com/drasko","followers_url":"https://api.github.com/users/drasko/followers","following_url":"https://api.github.com/users/drasko/following{/other_user}","gists_url":"https://api.github.com/users/drasko/gists{/gist_id}","starred_url":"https://api.github.com/users/drasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drasko/subscriptions","organizations_url":"https://api.github.com/users/drasko/orgs","repos_url":"https://api.github.com/users/drasko/repos","events_url":"https://api.github.com/users/drasko/events{/privacy}","received_events_url":"https://api.github.com/users/drasko/received_events","type":"User","site_admin":false},"created_at":"2015-05-03T18:11:27Z","updated_at":"2015-05-03T18:11:27Z","body":"After some thinking, I got a conclusion that `listener_thread` (https://github.com/nodesign/weio/blob/master/weioRunner.py#L320), that gets a messages from Python and pushes them to SockJS Websocket connections hits the exception at one point and dies.\r\n\r\nAfter that server push will never work, as there is no running thread to accept messages from Python and send them back to JS frontend. All JS functions calls will be unanswered - they will still be accepted and executed on the board, but no result will be sent back to JS.\r\n\r\nCurrently the only way to restart `listener_thread` is restarting the sever itself, as it is started only once, on the weioRunner.py user Tornado start: https://github.com/nodesign/weio/blob/master/weioRunner.py#L464"}}