Python HTTP 599: Connection closed (Tornado) -


i'm getting error:

http 599: connection closed [e 130405 11:43:14 web:1031] uncaught exception /networks/1/sensors/1/alarm (127.0.0.1)

while executing following code:

from tornado.stack_context import exceptionstackcontext  def handle_exc(*args): print('exception occured') return true  @tornado.gen.engine def check_status_changes(netid, sensid):      como_url = "".join(['http://131.114.52:44444/ztc?netid=', str(netid), '&sensid=', str(sensid), '&start=-5s&end=-1s'])      http_client = asynchttpclient()     response = yield tornado.gen.task(http_client.fetch, como_url)      if response.error not none:             print("terzo")             print response.error             exceptionstackcontext(handle_exc):                 response.rethrow()     else:         print('handle request')      line in response.body.split("\n"):                 if line != "":                      #net = int(line.split(" ")[1])                     #sens = int(line.split(" ")[2])                     #stype = int(line.split(" ")[3])                     value = int(line.split(" ")[4])                     print value                     yield value                     return   class alarmhandler(basehandler):     @tornado.web.authenticated     @tornado.web.asynchronous     @tornado.gen.engine     def get(self, netid, sensid):         self.lock_tables("read", ['devices'])         status = self.db.get("select status devices \                           id=%s , network_id=%s", sensid, netid)         print("primo")         print status          try:             periodic = tornado.ioloop.periodiccallback(check_status_changes(netid, sensid), 5000)             value = periodic.start()             print("secondo")             print value         except:             print("quarto")             periodic.stop()             self.finish()             return         if value != status['status']:              self.lock_tables("write", ['devices'])             self.db.execute("update devices set status=%s \                              id=%s , network_id=%s", value, netid, sensid)             self.unlock_tables()             self.notice("status changed") 

in class alarmhandler there periodic routine called check_status_changes. in function, obtain error of title when there's response.error.

how can set if error condition in order return class , manage situation? thank you.

other informations

if screen of tornado, see this:

primo

{'status': none}

secondo

none

terzo

http 599: connection closed

exception occured

so, think program close connection before exception rethtow!

and in html consolle see error:

file "./wsn.py", line 226, in check_status_changes line in response.body.split("\n"): attributeerror: 'nonetype' object has no attribute 'split'

you raising exception:

if response.error:         print("terzo")         print response.error         raise exception(response.error)         return 

this uncaught exception. should code handle exception without raising exception. e.g. log error message , abort database update.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -