Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Nicholas Amorim
    @nicholasamorim
    @connessionetech there isn’t much to it. We perform some inilization of some asyns components in setUp - which works by running ioloop.IOLoop.current().run_sync(my_stuff).
    For the actual tests, you just have to add @gen_test decorator:
    from tornado.testing import AsyncTestCase, gen_test
    
    class TestSomething(AsyncTestCase):
    
    @gen_test
    async def test_something_async(self):
        await my_modern_async_function()
    
    @gen_test
    def test_something_else_async(self):
       yield another_async_function()
    CTS
    @connessionetech
    Ok will try. Thanks
    CTS
    @connessionetech
    So I came across aiofile which js very good for async read and write. But there is no library for async directory listing, delete , create etc. What can I do ?
    Is there as way to convert legacy sync methods to async ?
    Ben Darnell
    @bdarnell
    the only generic solution is to run things in a thread pool
    CTS
    @connessionetech
    Mr Ben, Can you please point me to some example(s) ?
    Ben Darnell
    @bdarnell
    use IOLoop.run_in_executor. Here's an example where DefaultExecutorResolver uses this to call the synchronous getaddrinfo function: https://github.com/tornadoweb/tornado/blob/c92b883f806d99b35af52464980722c9c9a36a13/tornado/netutil.py#L399-L405
    CTS
    @connessionetech
    Thanks
    Bryan Van de Ven
    @bryevdv
    @bdarnell I seem to recall in the past there was some overridable "auth hook" method for request handlers. I can't seem to find it anymore tho, is there something like that? I'd like to expose it to Bokeh users so they can apply their own custom auth criteria easily
    Ben Darnell
    @bdarnell
    @bryevdv the hooks are get_current_user and get_login_url, although they're kind of an awkward fit for modern development patterns. they're only loosely connected to the rest of tornado so if they're not working for you feel free to just replace @authenticated and those two methods with something else
    Bryan Van de Ven
    @bryevdv
    Thanks Ben
    Nicholas Amorim
    @nicholasamorim
    I’m under the impression that asyncio.create_task does not work with @gen.coroutine - is that the case?
    TypeError: a coroutine was expected, got <Future pending…etc...
    Ben Darnell
    @bdarnell
    correct. it's not necesary. @gen.coroutine functions create their own tasks
    Nicholas Amorim
    @nicholasamorim
    so if I don’t await them (fire-and-forget) won’t asyncio complain? as it’s usually the case with asyncio’s own coroutines
    It does work with the lower-level ensure_future, which makes sense if the task is already created and a Future is returned
    Ben Darnell
    @bdarnell
    no, asyncio won't complain if you don't await @gen.coroutine functions (although it'll log their exceptions if they raise one)
    Nicholas Amorim
    @nicholasamorim
    Yeah, totally makes sense now. If they create their own Task, it’s the basically the same as running create_task anyways
    Thanks!
    CTS
    @connessionetech
    What is the standard and recommended way to run tornado app as service including autostart and all for production? I searched on supervisord and systemd but there aren't complete examples. Just snippets or half done stuff. I tried to get it working but didn't wokr
    CTS
    @connessionetech
    Another question : how to add any python mqtt client to tornado app ?
    CTS
    @connessionetech
    Paho-mqtt
    CTS
    @connessionetech
    Any info?
    Florian
    @FWirtz
    Hey, I have a question about the CSRF, anybody around? :blush:
    Florian
    @FWirtz
    Leonardo Dutra
    @dutraleonardo
    Hi guys, somebody tried to integrate tornado and celery using redis?
    Florian Best
    @spaceone
    Hi, I have a tornado web application which binds to UNIX sockets and starts mutliple processes. But somehow only one process answers the requests. Doesn't this work with multiprocessing?
    Ben Darnell
    @bdarnell
    it should work, but the kernel has a tendency to re-wake the same process repeatedly, so the other processes may not start to get traffic until the first process is busy when the request comes in
    Florian Best
    @spaceone
    @bdarnell thanks :-) at least with a TCP socket i could see that different process id's are used. but i can't with UNIX sockets
    Florian Best
    @spaceone
    How can I start a function only in the parent process after server.start(0). It seems the main process never returns in start() (different to os.fork() which returns process id's). is there some event queue which i can put functions into without calling tornado.ioloop.IOLoop.instance() ?
    Ben Darnell
    @bdarnell
    no; in tornado's multi-processing support the parent process's only role is supervising the children and you can't do other things in it. you can inspect tornado.process.task_id() to make one of the children do your "only one process" work
    Florian Best
    @spaceone
    @bdarnell okay, then i will do this instead.
    last question for today: I have the problem that i need to proxy the request depending on the Accept-Language header
    that's why I start one tornado application with TCP, which starts N (n = number of supported languages) processes with UNIX sockets
    I couldn't get this working with multiprocessing yet.
    maybe there is already another solution for this problem?
    Ben Darnell
    @bdarnell
    if the processes aren't all doing the same thing, i wouldn't fork them all off from the same parent process. start them all separately from systemd/supervisord
    Bryan Van de Ven
    @bryevdv
    @bdarnell is there any known way to implement sticky sessions in conjunction with --num-procs > 1?
    Ben Darnell
    @bdarnell
    @bryevdv No. You need an active load balancer for sticky sessions, not just a shared bound port
    Bryan Van de Ven
    @bryevdv
    @bdarnell OK that's what I thought, but I wanted to make sure
    Thanks!
    Afonso Pinto
    @afonsobspinto
    Hello, how are y'all? I'm trying to compress (gzip) the assets that are loaded in the browser by my jupyter notebook (mainly main.bundle and common.bundle); but I don't seem to find any information on how to do this with tornado? Could someone point me in the right direction?
    Ben Darnell
    @bdarnell
    @afonsobspinto You can pass compress_response=True to the Application constructor to enable compression
    it only compresses certain mime types (anything starting with text/ and the ones listed at https://github.com/tornadoweb/tornado/blob/865b6f7298f13d27423dba9fa907a1d2f8bdc1c0/tornado/web.py#L3069-L3079 )
    Tobias Bartsch
    @tobiasbartsch
    Hi, I am developing an app based on bokeh server (which uses tornado). I am trying to attach an async function to tornado's IOloop and have it be spawned periodically. However, there is no periodic version of IOLoop.spawn_callback. Is there a way to accomplish this? tornado.ioloop.PeriodicCallback does not seem to work for async functions.
    Varthaman-Hindustan 🇮🇳
    @kvivek_anandan_twitter
    tried to start Tabpy server for integrating python with tableau. with google I downgraded tornado 6 to tornado 5.1.1......using pip command, unfortunately I forgot and also could not trace that blog again......can anybody tell the full command.........
    Ben Darnell
    @bdarnell
    @tobiasbartsch i would just use spawn_callback to start a function that loops and calls await tornado.gen.sleep(...) and then calls the real function
    Zach Hammer
    @zhammer

    hey all - i made a codemod for replacing tornado gen coroutines with native async/await functions a while back and have been using it for upgrading some code at work. it's built on instagrams new libcst python codemod library.

    thought i'd share it here in case anyone wants to use it! https://github.com/zhammer/tornado-async-transformer

    Jesper Wendel Devantier
    @jwdevantier

    Hey. I'm having a problem where, in Tornado, specifically in some tests using the AsyncTestCase class, I observe a tendency for SqlAlchemy objects/models to become detached after yield'ing in my code. Is there a way to work around this ??

    (Admittedly may be wrong here, it's my working hypothesis)

    zejn
    @zejn
    Hi folks! Just a heads up: if you're doing a lot of HTTPS or WSS connections (or retrying a lot), AsyncHTTPClient has a leak when doing TLS handshakes and may exhaust open file limit. More at tornadoweb/tornado#2785