Questions tagged [tornado]
Tornado is a scalable web server and web framework for Python specializing in handling thousands of simultaneous connections and real-time services.
3,719
questions
-1
votes
0
answers
12
views
tornado: HTTPStreamClosedError
I'm trying to test my tornado-App like so:
from tornado.testing import AsyncHTTPTestCase
from tornado.web import Application
class TestSomeHandler(AsyncOpenAPITestCase):
@property
def ...
0
votes
0
answers
10
views
Not raising error when I log in with a wrong user, SQLITE + Tornado
I am developing a simple login application using tornado and SQLITE. When I login the application does what I expect, the user get redirected to his route, https://some_url/user_n. My problem came ...
0
votes
0
answers
12
views
Restric logged users to access unwanted url routes in a tornado server
I am trying to restrict logged user to access URL routes that are not assigned to them. As soon a user had logged, for example user1, will be redirected to https://myurl.com/user1. So far, that works ...
0
votes
0
answers
20
views
How do I mock an HTTPResponse with image data in tornado?
Problem
I am testing a handler for a tornado web application. This is my test case:
class HandlerTestCase(tornado_openapi3.AsyncOpenAPITestCase):
def get_app(self) -> Application:
...
1
vote
1
answer
15
views
Tornado error about attributes when deploying a server
I'm trying to run a program that works with Tornado (https://github.com/oduwsdl/CarbonDate), however, when I try to deploy a server with it, I get multiple errors from Tornado. I'm a bit exhausted, so ...
1
vote
1
answer
58
views
API testing: How do I mock/patch a method in one place only?
I am trying to patch/mock a method (AsyncHTTPClient.fetch) that is being called in two different places in my program: Firstly in tornado_openapi3.testing and secondly in my_file. The problem is that ...
1
vote
1
answer
16
views
does nest-asyncio runs coroutins on separate thread?
We're using tornadoweb which already runs an event loop single-threaded, and we want to use asyncio.run to run other coroutines, but it show error 'Event loop already running', found this library nest-...
0
votes
1
answer
42
views
Django 3.2 ORM integrated in Tornado server
We're using django 2.2 before and can integrate django orm with our non-async tornado handlers but we're going to upgrade to django 3.2 where you can't run django orm(non-async) in a tornado handler(...
0
votes
2
answers
76
views
API headers not working in Python-Tornado when front end makes requests
I've got a basic CRUD application, and I'm trying to get React-Redux on localhost:3000 to make requests to the backend, Python-Tornado (using pymongo for the database) at 127.0.0.1:8888. At first ...
1
vote
1
answer
39
views
Migrating a Python Backend from Flask to Tornado
I've already created a working CRUD app with the backend done in Python-Flask and Python-PyMongo, but now I need to migrate the backend from Flask to Tornado. There isn't very much up to date ...
2
votes
0
answers
34
views
Python render_template asynchronous w/ celery
I am going to make an app where every 200ms, the input value is taken and the python webpage should update. However, render_template updates the webpage when run, and therefore hurts the viewer's eyes ...
0
votes
1
answer
29
views
How to avoid messy error handling in Tornado RequestHandler
Say I have a simple RequestHandler like this.
class RequestHandler(web.RequestHandler):
def get(self, id, status):
obj = self.retrieve_object(id)
obj.update({"status": ...
0
votes
0
answers
32
views
Nginx Tornado WSS and PHP
Good morning,
I have the following concern, I am trying to configure NGINX with SSL with 2 applications (subdomains),
one is with WebSocket (Python-Tornado) and the other is a manager developed in PHP....
0
votes
1
answer
25
views
ndarray is not JSON serializable TypeError on working script (Tableau Prep - TabPy)
I have working code using test data, seen here:
(sample data matches type and format of inputs that I will be using this script with later, including dates as strings appended with 'Z')
from ...
0
votes
1
answer
32
views
how to define origin_check in pywebio start_server
I have a small test script where I'd like to check the pywebio start_server arguments. But neither allowed_origins nor check_origin seems to work in my script:
from pywebio import start_server
from ...
0
votes
0
answers
49
views
Python panel (bokeh) server connection display empty html page without error message
I have a Django project where one view function start a bokeh server by a python script.
Popen(["panel", "serve", "/opt/bitnami/projects/blog/EnviAI/scripts/visz_pn_ssm_1.py&...
0
votes
0
answers
25
views
how to return any file present in directory as a part of curl GET call
I am using tornado framework and trying implementing static file download functionality (I know we can use like below by specifying static_url_prefix so It will create handler and whenever we will use ...
0
votes
0
answers
23
views
how to implement separate handler for static file check authentication curl -tornado application
I am new to tornado web framework. I have below code.
static_path = pathlib.Path(pkg_resources.resource_filename("abcd.app.data", "web"))
self.application = tornado.web.Application(...
0
votes
1
answer
41
views
Call an async function periodically on a Tornado web server?
I have a web site using Tornado. And I need to call a function (do_work() in the following exmaple) periodically.
import asyncio
import datetime
from typing import Any, Callable, Coroutine
import ...
0
votes
0
answers
17
views
Trying to Understand tornado.options.define
I am brand new to tornado. I have been reading documentation (https://www.tornadoweb.org/en/stable/options.html) about tornado.options.define trying to understand how it works.
It seems the default ...
0
votes
0
answers
25
views
Tornado, six & others uninstalled by another module, how do I fix it?
I'm new to python. I use Jupiter locally and typed:
python3 -m pip install google-colab
in Mac terminal. I needed the module for an online course and red elsewhere I could import it like this. But ...
0
votes
1
answer
37
views
can we start multiple clients. tornado client-side?
class DetectClient(object):
def __init__(self, url):
self.url = url
self.ws = None
self.connect()
PeriodicCallback(self.heartbeat, 3000).start()
IOLoop.instance().start()
@gen....
0
votes
0
answers
19
views
Passing a Tornado Future into a function that accepts a Tornado Coroutine
If we have a function uneditable_function that should not be changed,
@tornado.gen.coroutine
def uneditable_function(coro, *args, **kwargs):
res = yield foo(coro(*args, **kwargs))
return ...
0
votes
0
answers
42
views
Question for "RuntimeError: There is no current event loop in thread 'Thread-1'"
I am relative new to python. So here is my question.
In main.py I initialize two classes and a tornado webservice:
plotter = Plotter(config=Config)
plotter_thread = PlotterThread(config=Config, ...
0
votes
1
answer
36
views
Tornado Coroutine fails with 'dict' object not callabale
Python version: 3.6
I am not super expert in Python, I was trying to use Tornado to implement a simple REST server and use non blocking coroutine to call a blocking function. When I return Json from ...
0
votes
0
answers
67
views
Django for TCP/IP and Websockets connections
I am building a trading back-end that provides live streaming prices (over Websockets) and trading functionality (REST endpoints) to the web client. The back-end was planned to be build with Django. ...
0
votes
0
answers
67
views
How to stop tornado.ioloop PeriodicCallback after certain retries
I am new to using tornado, struggling with a scenario when the periodic callback is made to github if for any reason github service is not reachable then IOloop.PeriodicCallBack is stuck is infinite ...
0
votes
1
answer
64
views
Render html response from string in python tornado library
I need to render response from html string in tornado like this:
self.method_to_render_html_from_string('<h1>Hello</h1>')
How can I do it? Tornado version is 6.1.
Here how it's displayed ...
1
vote
1
answer
4k
views
Parse Error: The server returned a malformed response - Error: Parse Error: Expected HTTP/ - when trying to access one of my app URLs with postman
I am managing an app built by third parts in python.
I have this url dispatcher
urls += [(r'/path/objectA/(.*)', ObjectAHandler)] # this was made by third parts, it is expected to work
and this ...
0
votes
0
answers
37
views
Tornado application takes a long time to shut down
My Tornado (with Asyncio) application sometimes takes a long time to shut down after I press Ctrl+C.
It seems to shut down sooner if it receives a network request after I press Ctrl+C, which suggests ...
0
votes
2
answers
131
views
Tornado gives error Cannot write() after finish()
I am using the Tornado chat demo example from here: https://github.com/tornadoweb/tornado/tree/master/demos/chat
and just altering it very slightly.
The code change is just a small class called ...
3
votes
1
answer
126
views
Tornado & Apache reverse proxy can't get the right configuration
I am using apache to reverse proxy several app and expose only 1 port and 1 ssl certificat. I have manage to make it works for most of the apps but all webapp based on tornado can't follow the reverse ...
0
votes
1
answer
39
views
Tornado: Is the RequestHandler.on_finish() method guaranteed to be called?
As the title asked: Is the RequestHandler.on_finish() method guaranteed to be called? Even if, say, the .post() method had an unhandled Exception?
0
votes
1
answer
223
views
Coroutine was never awaited in Tornado
I'm trying to learn asynchronous call in Python, and here's my code:
class MyClient:
def _init_(self):
async def method(self):
print("xxxxxxx")
And also:
def test_my_client(...
1
vote
1
answer
36
views
How to call Python Tornado Websocket Server inside another Python
I would like to implement Python Tornado Websocket Server inside another Python (main) and trigger send messages when needed. The main creates two threads. One of them is for Python Server and the ...
0
votes
1
answer
61
views
Tornado, how to drop POST/GET with 401 if a token is not provided
I want to drop GET/POST requests if a token field is not provided in the headers.
Currently I use this code (from GitHub Gist):
def require_basic_auth(handler_class):
def wrap_execute(...
0
votes
1
answer
224
views
How to send ros2 messages from a websocket server to connected clients in tornado
I have a ros2 publisher script that sends custom messages from ros2 nodes. What I need to do is to have a subscriber (which is also my websocket server) to listen to the message that the pulisher ...
0
votes
0
answers
34
views
How to close socket once receiving request immediately before processing the request using tornado?
after receiving a post,the server close the socket immediately with self.finish().After that the server processes the request.
However,if the server received another request at the same time,the ...
1
vote
0
answers
167
views
Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state
I am trying to stream video. The script work fine locally but gives following error when i moved to server
Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
...
1
vote
0
answers
118
views
How to interpret py-spy profiling results from tornado web server?
I'm trying to profile a tornado web server running in a docker container using py-spy.
I used the instructions at https://github.com/benfred/py-spy to set up the profiling workflow and it seems to ...
0
votes
1
answer
51
views
how to pass data to modal to dynamically construct modal using bootstrap4.6
Recently I moved to adminLTE3(using bootstrap 4.6) and use it as a front-end framework for Tornado. I encounter a problem with modal.
In the old version of adminLTE(using bootstrap 3.3), I can ...
1
vote
1
answer
578
views
'Collection' object is not callable. If you meant to call the 'save' method on a 'Collection' object it is failing because no such method exists
I am using tornado to build a simple website with mongoDB. I used python 3.7 and latest version of pymongo to control data in MongoDB but when I edit data in MongoDB with save methods as code below, ...
-1
votes
1
answer
46
views
Handling or accessing file on in the RequestHandler uploaded in the POST request
Through POST request from postman i am sending multipart/ form-data with parameters along with file attachments. Now on the backend I am using tornado to handle these requests, I have no problem ...
1
vote
2
answers
109
views
How to increase HTTP header size in Jupyter?
When working with matplotlib widgets and k3d to visualize 3D data, the requests are constructed such, that the graphical data is being packed into the HTTP header. This header size is limited in the ...
-1
votes
1
answer
38
views
Retrieve form-data body using tornado on server side
As shown in the picture i am doing a mutlipart/ form-data POST from postman and trying to get the body using tornado in the backend. But as per the documentation I have been using "...
0
votes
0
answers
98
views
How to dynamically change HTML content with tornado python backend
My website looks like this.
<html>
<body>
<form action="" method="post">
<input type="submit" value="previous" ...
0
votes
0
answers
32
views
How to break out of the loop when closing the front end tornado websocket
class EchoWebSocket(tornado.websocket.WebSocketHandler):
def open(self):
print("WebSocket opened")
@gen.coroutine
def on_message(self, message):
self.log = ...
0
votes
1
answer
50
views
How replace None with empty string in Tornado template
I have some models from SQL-Alchemy passing to generate function:
from tornado import template
loader = template.Loader('.')
template = loader.load('index.html')
content = template.generate(user=user)
...
0
votes
0
answers
56
views
How to pass data from mqtt subscriber to tornado websocket?
I have a MQTT publisher which is publishing the json data and that is being subscribed. I want to take this subscribed mqtt message and pass it to tornado websocket. But how can i pass the data in ...
0
votes
1
answer
50
views
Python tornado has a big time difference between the request from the client and the execution of the view
I use tornado framework to build a web server, but I have encountered some problems. There is a big time difference between the request from the client and the execution of the view. What should I do?
...