1. Using asynchronous for loops in Python

    asyncio has brought support for asynchronous I/O with an event loop to Python 3. Since Python 3.5, we can use the async and await keywords:

    async def get(self):
        await self.wait_for_token()
        return self.client.get()
    

    But Python 3.5 also brought support for asynchronous context managers (async …

    read more

    There are comments.

  2. Indenting JSON in Python

    Main JSON railroad diagram - http://www.json.org/fatfree.html

    At work, I recently wanted to visualize how we annotated documents that we store as JSON in Elasticsearch. We annotate substrings with different codes, and I wanted to show those codes using colors in a terminal. This basically boils down to outputting JSON with ANSI escape codes. The easier part …

    read more

    There are comments.

  3. How do you limit memory usage with asyncio?

    One of the first hurdles that you can encounter when trying out asyncio is "asyncio eats all my memory!". Indeed, to keep your CPU busy, you're encouraged to launch a lot of coroutines simultaneously. Coroutines don't use a lot of memory by themselves, but what you're doing inside them can …

    read more

    There are comments.

Page 1 / 3 »