Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Marko Mrdjenovic
    @friedcell
    So my issue is how to support t5 on py3.5 and py3.6 if at all
    (since StackContext is gone in t6, it can only be supported on py3.7)
    Interview
    @interviewer_gitlab
    anyone around?
    0chandansharma
    @0chandansharma
    Hi, I am trying to use tornado server with my AI model, the problem is server started responding late concerning time, example: I am using server continuously, initially, the results are coming within 1 sec and after using few hours I am started getting late response, i.e., around 5 to 6 min delay, I am attaching my code for the same.................. I think I am missing something to clean the threads, please correct me....
    https://ide.geeksforgeeks.org/66BOohBXCu
    0chandansharma
    @0chandansharma
    @bdarnell
    Marko Mrdjenovic
    @friedcell
    @0chandansharma what python/tornado is this?
    Marko Mrdjenovic
    @friedcell
    @0chandansharma if I'm reading this right you're looping in while True and not releasing to other requests until 0.1s elapses. I'd set interval before while True and then inside while True first do sleep = gen.sleep(interval) and at the end of the block do yield sleep. and also remove the if as sleep will ensure you don't get stuff faster than interval
    I assume cam.getFrame is not a cheap operation - and it is synchronous, so it blocks all requests on the server. might make sense to:
    1) do it in an executor
    2) cache its results so that if there are multiple requests you don't fetch the same frame multiple times
    chwba
    @chwba
    anyone around?
    Greg Werner
    @jgwerner
    howdy!! has anyone encountered samesite issues with the latest version of chrome (8.x) when using set_secure_cookie?
    st3vo7
    @st3vo7
    Hello everyone. How can I detect AJAX request? By using self.request.body, I am not getting the data created through AJAX' POST method.
    hoseinmontazer
    @hosein33

    Hello
    I developed one of the demo programs (chat)
    But the problem I encountered is that I can't display a image(url) in the tepmplate html
    in index.html i have

    class MessageNewHandler(BaseHandler):
    """Post a new message to the chat room."""
    def post(self):
    img_url = UsernameFinder.find_Avatr(self)

        name = UsernameFinder.find_screenName(self)
        body= self.get_argument("body")
        message = {"id": str(uuid.uuid4()), "img_url": str(img_url) ,"name": name ,"body":body}
        #message = {"id": str(uuid.uuid4()), "img_url":img_url ,"name": name ,"body":body}
    
        message["html"] = tornado.escape.to_unicode(
            self.render_string("message.html", message= message)
        )
    
        if self.get_argument("next", None):
            self.redirect(self.get_argument("next"))
        else:
            #name = tornado.escape.xhtml_escape(self.current_user)
            print(type(message))
            self.write(message)
        global_message_buffer.add_message(message)

    Now how can I show img_url , and name and body in seperate <td>

    Novski
    @novski

    Does anyone have a good reading resource about async coroutines in tornado?

    I’m searching for a sample of a coroutine added to what is documented in tornado.locks.
    My test throws the widely discoussed was never awaitederror. But helpful resources are always for pythonic not tornado solutions...

    Novski
    @novski

    Does anyone have a good reading resource about async coroutines in tornado?

    I’m searching for a sample of a coroutine added to what is documented in tornado.locks.
    My test throws the widely discoussed was never awaitederror. But helpful resources are always for pythonic not tornado solutions...

    the doc’s have that documented in a other section: https://www.tornadoweb.org/en/stable/guide/coroutines.html
    I did not see that.

    Novski
    @novski
    Well it turns out to not be quite complet.
    Does anyone know the tornado equivalent of:
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    loop.run_until_complete(my_async_func())
    Bruno P. Kinoshita
    @kinow
    @novski I think they have that documented in their IOLoop section of the docs https://www.tornadoweb.org/en/stable/ioloop.html
    Luke Hinds
    @lukehinds
    what's the current method of seeing incoming requests in tornado - namely the full url called if possible?
    Luke Hinds
    @lukehinds
    I can see self.request , but would like the whole thing is possible
    https://<ip>:<port>/path/to/handler?<etc>
    kAldown
    @kaldown
    Hi guys. Sorry for asking. But I've read tons of stackoverflow examples and other explanations from sites. Still not sure if I'm doing right thing with semi-long running blocking task. https://stackoverflow.com/questions/61516148/write-back-through-the-callback-attached-to-ioloop-in-tornado. I know you tired solving peoples obvious mistakes. But I tried to minimize amount of stupid mistakes. And understand that my blocking DB and IO calls aren't asynchronous and should be managed in Thread or being delegated into a worker. Yet. Do you see any flaws, or maybe I'm doing something completely wrong? Thanks a lot!
    zejn
    @zejn
    @lukehinds self.request.full_url() works for me
    zejn
    @zejn
    @kaldown I've commented on your SO question.
    kAldown
    @kaldown
    @zejn thank you. I responded :)
    Still I think it would be better to create global ThreadPoolExecutor then set it to ioloop and then use via interface, without being afraid to create fork bomb calling some inner code with the different ThreadPoolExecutor instance
    zejn
    @zejn
    Sure. That obviously depends on what you are trying to achieve, eg. you can have one global executor, but use another for something very specific.
    kAldown
    @kaldown
    The problem is exactly in cross computations. We have old self written framework to handle DB queries with mongodb, using ThreadPoolExecutor. I'm curious if calling that queries from withing this blocking function handler would be a huge mistake.
    st3vo7
    @st3vo7
    Hey people, I need some advice, perhaps somebody can help. I am implementing simple Sign-up/ Log-in functionalities on my page and I want to connect it to database (meaning, when user signs up, I want to store his credentials in my database and to look it up from db when he wants to log in). Furthermore, user should be able to save some data, and access it later. Now, I am not sure which DBMS to use. Is it better to be SQL-ish like (PostgreSQL with AIOPG) or is it MongoDB (with Motor library for asynchronous style) better way to go? Many thanks!
    Robbie Capps
    @rocapp
    I use Firebase from Google
    There's a Python SDK
    Also a good open source api wrapper called pyrebase
    Zachary LeFevre
    @zachlefevre
    Is there any way to measure request latency (including time waiting to be handled?
    gefrag
    @gefrag
    @zachlefevre you can override the on_finish method and add there your logic to measure the duration of a handler
    梁先森
    @LiangXianSen
    @zachlefevre a built-in method self.request.request_time()
    hello, guys ~
    Is there a trick could inject an obj into each tornado handlers ?
    梁先森
    @LiangXianSen
    one I knew is let it in my basehandler, Is there others?
    ehds
    @ehds_gitlab
    Why did I use tornado.gen.sleep(2) in async def get() work,but asyncio.sleep(2) not work?
    Why did I use tornado.gen.sleep(2) in async def get() work,but asyncio.sleep(2) not work?
    raise loop = events.get_running_loop() RuntimeError: no running event loop
    gefrag
    @gefrag
    hello, is there a way to get the full path of a template inside the template itself ?
    If I have in a handler this self.render('login.html')
    and in login.html I put something like this {{ __name__ }} I get login_html on the browser
    the only reason I want this is to display extra "debugging" information for other devs when working on a development env.
    Rick Nitsche
    @nritsche
    Hi,
    is there a way to tell Tornado about the URL root of my web app?
    I am supplying an authentication module with auth_provider, if I set the login_url in there to /login, the login page is correctly served on host/rooturl/login, but If I access host/rooturl with my browser, I get redirected to host/login.
    Now if I set login_url to /urlroot/login, it gets served at host/urlroot/urlroot/login.
    Naveen Michaud-Agrawal
    @nmichaud
    can't find this anywhere, but can't Tornado's StaticFileHandler serve already gzipped resources (with the appropriate encoding headers)?
    Kirill Plotnikov
    @pltnk
    Hi everyone! Could you please tell me what is the best and most modern way to connect tornado server to Redis? I found libs like tornado-redis, toredis, brukva but it seems like they are not maintained anymore. Will something like aioredis, aredis, asyncio_redis work properly with tornado? Are there any caveats? Thanks in advance!
    Kirill Plotnikov
    @pltnk
    Looks like tornado works well with aredis.
    Marko Mrdjenovic
    @friedcell
    @pltnk unless you're using long-running stuff in redis, you're good with redis-py
    even if you do, I'd suggest you use redis-py for fast, sync stuff
    Novski
    @novski

    Hey. Im running a mozilla-webthing-python that is built upon tornado and i have it on a small IOT Device that has GPIO. It supports intel MRAA Framework and i use it with a interrupt function.

    Too much informaiton?
    Well just forget the details. The Problem i walked in to is that it generates a new thread and im wondering how i can reach the MainThread again?
    Any ideas?

    Novski
    @novski
    tornado.ioloop.IOLoop.current().time() is 1h behind my real time. How to convert to local time?
    Patrick Woo
    @agileurbanite

    hello, is there a way to just gzip compress requests for static assets? this setting

    --NotebookApp.tornado_settings='{ "compress_response": True }’

    seems to compress all requests not just requests for js and css assets

    Bruno P. Kinoshita
    @kinow
    @agileurbanite not tested, but maybe you could try modifying the request handler _transforms of a custom static file handler. And just add a GZip transformer as in the application
    Martin.
    @mfe__twitter
    hi, does tornadoweb requires the ctype python module?
    Ivan Trusov
    @renardeinside

    Hi everyone,

    I'm trying to use tornado App + socket.io for some tunneling.
    Imagine I would like to do the following - on every connection coming from the socket.io, I would like to add a new coroutine to the tornado loop. Coroutine method looks like this:

        async def read_routine(self):
            logging.info("Starting reading routine")
            while True:
                try:
                    if self.stream:
                        data = await self.stream.read_bytes(1024)
                        await self.io.emit("response", {"data": data})
                except Exception as e:
                    logging.error(f"Reading routine stopped with error {e}")
                    break

    I'm trying to add this callback to the ioloop:

        app = tornado.web.Application(
            [
                (r"/health", MainHandler),
                (r"/socket.io/", socketio.get_tornado_handler(handler.io)),
            ],
            debug=True,
        )
        app_port = 6006
    
        app.listen(app_port)
        loop = tornado.ioloop.IOLoop.current()
        loop.add_callback(handler.read_routine)
        logging.info(f"starting server on port {app_port}")
        loop.start()

    But it blocks the execution on the add_callback operation, so the application never starts. How to fix this?