Tornado 500 error

I'm not entirely certain these two examples are related, but they look similar aside from one with unhandled exceptions and one not. Both caused 500 errors from Tornado, after which it restarte...

Here’s another one. I was just bringing the client browser window to the foreground on my laptop when this happened. I haven’t rebooted yet, should do that now.

2016-12-10 10:39:44,784 INFO     Tornado  26.0% busy over the past 59.9 seconds
2016-12-10 10:39:49,784 INFO     Tornado  25.9% busy over the past 59.9 seconds
2016-12-10 10:39:55,171 INFO     Tornado  26.0% busy over the past 59.8 seconds
2016-12-10 10:40:00,283 INFO     Tornado  26.0% busy over the past 59.9 seconds
2016-12-10 10:40:05,284 INFO     Tornado  25.9% busy over the past 59.9 seconds
2016-12-10 10:40:08,570 INFO     127.0.0.1       GET     200  34ms (lp: 51.0s) (+start: 10ms) /json/events [1481332150:0/1/heartbeat] (ZOE@zulip.com via website)
2016-12-10 10:40:08,641 INFO     Received event: {u'status': 2, u'user_profile_id': 2, u'client': u'website', u'time': 1481384408}
2016-12-10 10:40:08,740 INFO     127.0.0.1       POST    200 116ms (db: 13ms/3q) (+start: 14ms) /json/users/me/presence (ZOE@zulip.com via website)
2016-12-10 10:40:10,784 INFO     Tornado  26.0% busy over the past 59.9 seconds
2016-12-10 10:40:15,784 INFO     Tornado  25.8% busy over the past 59.9 seconds
2016-12-10 10:40:21,166 INFO     Tornado  26.1% busy over the past 60.0 seconds
2016-12-10 10:40:22,360 INFO     Tornado dumped 1 event queues in 0.004s
ERROR:tornado.access:599 GET /json/events?dont_block=false&queue_id=1481332150%3A0&last_event_id=461 (x.x.x.74) 4739.77ms
Unhandled exception in thread started by <bound method Threaded_worker.__bootstrap of <Threaded_worker(Thread-1, stopped daemon 140444418004736)>>Unhandled exception in thread started by <bound method Threaded_worker.__bootstrap of <Threaded_worker(Thread-6, stopped daemon 140444382029568)>>
Traceback (most recent call last):

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
  File "/usr/lib/python2.7/threading.py", line 823, in __bootstrap_inner
    (self.name, _format_exc()))
  File "/usr/lib/python2.7/traceback.py", line 241, in format_exc
    etype, value, tb = sys.exc_info()
AttributeError: 'NoneType' object has no attribute 'exc_info'
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 823, in __bootstrap_inner
    (self.name, _format_exc()))
  File "/usr/lib/python2.7/traceback.py", line 241, in format_exc
    etype, value, tb = sys.exc_info()
AttributeError: 'NoneType' object has no attribute 'exc_info'
Exception in thread Thread-8 (most likely raised during interpreter shutdown):Exception in thread Thread-4 (most likely raised during interpreter shutdown):Exception in thread Thread-3 (most likely raised during interpreter shutdown):

Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
  File "/home/feorlen/zulip/dev/zulip/zerver/management/commands/process_queue.py", line 83, in run
  File "/home/feorlen/zulip/dev/zulip/zerver/management/commands/process_queue.py", line 83, in run  File "/home/feorlen/zulip/dev/zulip/zerver/management/commands/process_queue.py", line 83, in run
  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 106, in start

  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 106, in start  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 106, in start

  File "/home/feorlen/zulip/dev/zulip/zerver/lib/queue.py", line 168, in start_consuming  File "/home/feorlen/zulip/dev/zulip/zerver/lib/queue.py", line 168, in start_consuming


  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming  File "/home/feorlen/zulip/dev/zulip/zerver/lib/queue.py", line 168, in start_consuming  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming


  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 647, in process_data_events  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming

  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 647, in process_data_events  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 647, in process_data_events
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 598, in poll
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 598, in poll  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 598, in poll

<type 'exceptions.TypeError'>: 'NoneType' object is not callable
<type 'exceptions.TypeError'>: 'NoneType' object is not callable<type 'exceptions.TypeError'>: 'NoneType' object is not callable


Exception in thread Thread-9 (most likely raised during interpreter shutdown):Exception in thread Thread-7 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
Traceback (most recent call last):

  File "/home/feorlen/zulip/dev/zulip/zerver/management/commands/process_queue.py", line 83, in run  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner

  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 250, in start  File "/home/feorlen/zulip/dev/zulip/zerver/management/commands/process_queue.py", line 83, in run
  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 106, in start
  File "/home/feorlen/zulip/dev/zulip/zerver/worker/queue_processors.py", line 106, in start
  File "/home/feorlen/zulip/dev/zulip/zerver/lib/queue.py", line 168, in start_consuming

  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming  File "/home/feorlen/zulip/dev/zulip/zerver/lib/queue.py", line 168, in start_consuming

  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 647, in process_data_events  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 647, in process_data_events
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 598, in poll
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
  File "/srv/zulip-venv/local/lib/python2.7/site-packages/pika/adapters/select_connection.py", line 598, in poll

<type 'exceptions.TypeError'>: 'NoneType' object is not callable
ERROR:tornado.access:500 GET /json/events?dont_block=true&queue_id=1481332150%3A0&last_event_id=461 (x.x.x.74) 17.47ms
ERROR:tornado.access:500 GET /json/events?dont_block=true&queue_id=1481332150%3A0&last_event_id=461 (x.x.x.74) 17.39ms
ERROR:tornado.access:500 GET /sockjs/info?cb=z8fzff7y0h (x.x.x.74) 13.18ms
ERROR:tornado.access:500 GET /json/events?dont_block=true&queue_id=1481332150%3A0&last_event_id=461 (x.x.x.74) 13.29ms
Performing system checks...

System check identified no issues (0 silenced).
Validating Django models.py...
December 10, 2016 - 10:40:39
Django version 1.8.15, using settings 'zproject.settings'
Starting development server at http://127.0.0.1:9992/
Quit the server with CONTROL-C.
System check identified no issues (0 silenced).

Django version 1.8.15
Tornado server is running at http://127.0.0.1:9993/
Quit the server with CTRL-C.
2016-12-10 10:40:39,212 INFO     Tornado loaded 1 event queues in 0.000s
2016-12-10 10:40:39,221 INFO     Tornado  99.3% busy over the past  0.0 seconds
2016-12-10 10:40:40,975 INFO     14 queue worker threads were launched
2016-12-10 10:40:44,347 INFO     Tornado  20.3% busy over the past  5.1 seconds
2016-12-10 10:40:45,044 INFO     127.0.0.1       GET     200  12ms (+start: 49ms) /json/events [1481332150:0/1/restart] (ZOE@zulip.com via website)
2016-12-10 10:40:45,061 INFO     127.0.0.1       SOCKET  200   0ms /socket/open [transport=websocket] (unknown via ?)
2016-12-10 10:40:45,272 INFO     127.0.0.1       DELETE  200  27ms (mem: 10ms/1) (+start: 19ms) /json/events [1481332150:0] (ZOE@zulip.com via website)
2016-12-10 10:40:45,638 INFO     127.0.0.1       SOCKET  403 140ms (db: 22ms/3q) /socket/auth [transport=websocket] (unknown via ?)
2016-12-10 10:40:45,639 INFO     status=403, data=, uid=unknown
2016-12-10 10:40:47,097 INFO     127.0.0.1       GET     200  26ms /api/v1/events [1481384424:0/0] (ZOE@zulip.com via internal)
2016-12-10 10:40:47,520 INFO     127.0.0.1       GET     200  15ms (+start: 5ms) /api/v1/events [1481384424:0/0] (ZOE@zulip.com via internal)
2016-12-10 10:40:48,937 INFO     127.0.0.1       GET     200  1.9s (mem: 8ms/7) (db: 244ms/17q) (+start: 18ms) / [1481384424:0] (ZOE@zulip.com via website)
2016-12-10 10:40:49,711 INFO     Tornado  31.4% busy over the past 10.5 seconds
2016-12-10 10:40:52,568 INFO     127.0.0.1       SOCKET  200   0ms /socket/open [transport=websocket] (unknown via ?)
2016-12-10 10:40:52,935 INFO     Received event: {u'status': 2, u'user_profile_id': 2, u'client': u'website', u'time': 1481384452}
2016-12-10 10:40:53,189 INFO     127.0.0.1       SOCKET  200 181ms (db: 44ms/2q) /socket/auth [transport=websocket] (ZOE@zulip.com via ?)
2016-12-10 10:40:53,344 INFO     127.0.0.1       POST    200 577ms (mem: 156ms/2) (db: 69ms/3q) (+start: 28ms) /json/users/me/presence (ZOE@zulip.com via website)
2016-12-10 10:40:53,731 INFO     127.0.0.1       GET     200  1.0s (mem: 323ms/8) (db: 346ms/10q) (+start: 11ms) /json/messages [stream] (ZOE@zulip.com via website)
2016-12-10 10:40:53,804 INFO     127.0.0.1       GET     200 812ms (mem: 179ms/3) (db: 36ms/2q) (+start: 75ms) /json/messages (ZOE@zulip.com via website)
2016-12-10 10:40:53,989 INFO     127.0.0.1       POST    200  22ms (mem: 7ms/1) (+start: 73ms) /json/report_narrow_time [28ms/74ms/1181ms] (ZOE@zulip.com via website)
2016-12-10 10:40:55,061 INFO     Tornado  36.8% busy over the past 15.8 seconds
2016-12-10 10:40:55,066 INFO     127.0.0.1       SOCKET  408   0ms (db: 44ms/2q) /socket/close [transport=websocket] (unknown via ?)
2016-12-10 10:40:55,072 INFO     status=408, data=, uid=unknown
2016-12-10 10:41:00,212 INFO     Tornado  34.0% busy over the past 21.0 seconds
2016-12-10 10:41:04,300 INFO     127.0.0.1       GET     200 182ms (db: 11ms/2q) (+start: 14ms) /json/messages (ZOE@zulip.com via website)
2016-12-10 10:41:05,340 INFO     Tornado  32.7% busy over the past 26.1 seconds
2016-12-10 10:41:10,711 INFO     Tornado  31.4% busy over the past 31.5 seconds
2016-12-10 10:41:16,211 INFO     Tornado  30.5% busy over the past 37.0 seconds
2016-12-10 10:41:21,212 INFO     Tornado  29.9% busy over the past 42.0 seconds
2016-12-10 10:41:26,340 INFO     Tornado  29.7% busy over the past 47.1 seconds
2016-12-10 10:41:31,711 INFO     Tornado  29.3% busy over the past 52.5 seconds
2016-12-10 10:41:37,212 INFO     Tornado  29.0% busy over the past 58.0 seconds

I was in the need of letting users upload pictures from a PhoneGap application using Tornado on my server, so I used a piece of code found on another question:
How to upload an image with python-tornado from an HTML form?

The code as seen there works perfectly fine. But sadly what I’m sending to the server isn’t exactly a file, but a base64 encoded string. So I up a «test lab» on UNIX machine did some modifications on the code, so I would receive the string and another agrgument I needed to use to name the file after decoding the string. When I launch the service it starts normally, but when I try to access it from the browser, it instantly show 500: Internal Server Error. The only part of the code I modified was the UploadHandler, everything else is exactly the same. I’m pretty new to python so I know probably I did something wrong. Any help would be appreciated.

import tornado.httpserver, tornado.ioloop, tornado.web, os.path, random, string
from tornado.options import (define, options)

define("port", default=8884, help="run on the given port", type=int)


class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r"/", IndexHandler),
            (r"/upload", UploadHandler)
        ]
        settings = {
            'template_path': 'templates',
            'static_path': 'static',
            'xsrf_cookies': False
        }
        tornado.web.Application.__init__(self, handlers, **settings)


class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("subir-string.html")


class UploadHandler(tornado.web.RequestHandler):
    def post(self):
        b64string = self.get_argument("imageData","")
        v_id = self.get_argument("id","")

    if b64string:
        try:

            new_name = "uploads/%s.jpg" % v_id
            c = 0
            while  os.path.isfile(new_name):
                base, ext = os.path.splitext(new_name)
                new_name =  "uploads/%s-%s%s" % (base, c, ext)
                c= c + 1                    
            output_file = open(new_name, 'w')
            output_file.write(base64.decodestring(b64string))
        except Exception as e:
            print "Error: %s"%(e)
            self.finish(" Can't process request")
        else:
            self.finish(" File Uploaded " + new_name)

def main():
    tornado.options.parse_command_line()
    app = Application()
    app.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

if __name__ == "__main__":
    main()

I was in the need of letting users upload pictures from a PhoneGap application using Tornado on my server, so I used a piece of code found on another question:
How to upload an image with python-tornado from an HTML form?

The code as seen there works perfectly fine. But sadly what I’m sending to the server isn’t exactly a file, but a base64 encoded string. So I up a «test lab» on UNIX machine did some modifications on the code, so I would receive the string and another agrgument I needed to use to name the file after decoding the string. When I launch the service it starts normally, but when I try to access it from the browser, it instantly show 500: Internal Server Error. The only part of the code I modified was the UploadHandler, everything else is exactly the same. I’m pretty new to python so I know probably I did something wrong. Any help would be appreciated.

import tornado.httpserver, tornado.ioloop, tornado.web, os.path, random, string
from tornado.options import (define, options)

define("port", default=8884, help="run on the given port", type=int)


class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r"/", IndexHandler),
            (r"/upload", UploadHandler)
        ]
        settings = {
            'template_path': 'templates',
            'static_path': 'static',
            'xsrf_cookies': False
        }
        tornado.web.Application.__init__(self, handlers, **settings)


class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("subir-string.html")


class UploadHandler(tornado.web.RequestHandler):
    def post(self):
        b64string = self.get_argument("imageData","")
        v_id = self.get_argument("id","")

    if b64string:
        try:

            new_name = "uploads/%s.jpg" % v_id
            c = 0
            while  os.path.isfile(new_name):
                base, ext = os.path.splitext(new_name)
                new_name =  "uploads/%s-%s%s" % (base, c, ext)
                c= c + 1                    
            output_file = open(new_name, 'w')
            output_file.write(base64.decodestring(b64string))
        except Exception as e:
            print "Error: %s"%(e)
            self.finish(" Can't process request")
        else:
            self.finish(" File Uploaded " + new_name)

def main():
    tornado.options.parse_command_line()
    app = Application()
    app.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

if __name__ == "__main__":
    main()

Понравилась статья? Поделить с друзьями:
  • Tormax автоматические двери коды ошибок
  • Torchlight runtime error
  • Torchlight 2 ошибка брандмауэра решение
  • Torchlight 2 как изменить уровень сложности
  • Torch not compiled with cuda enabled ошибка