Feng's Notes Isn't coding fun?
Posts with the tag Python:

Run Multiple Asyncio Frameworks, is it possible?

The answer is yes. But it’s not a trivial task. I had this question when I was working on a telegram bot with python telegram bot(PTB) framework, while I also want to run a fastapi server using uvicorn. PTB is built on top of asyncio and if you run Application.run_polling() it will block the event loop. So I had to find a way to let both run without blocking.

Option 1: Embed the other asyncio frameworks in one event loop

Actually this is the recommended way to run multiple asyncio (including webserver or another bot), the given example is as follows:

Task queues in different languages

Task queue is used widely in software development. It is a mechanism to distribute work across threads or machines. It is also a way to coordinate workers to perform tasks. The scenario could be a web application that needs to process a large number of requests, a data pipeline that needs to process a large amount of data or a scheduled job that needs to run periodically. I have used task queues in different languages. In this post I will recall my experience with task queues that implemented in Python, Java, Node.js and Golang.

Streamlit app to manage your cloudflare images

In my previous article I introduced how to build a sql chatbot with langchain and streamlit. I was then thinking if I can use streamlit to manage my image gallery on cloudflare. I found it was as easy as I thought, of course with a bit help of chatgpt..

Why I need this

I have been using cloudflare images service for a while and satisfied with its speed. However, it doesn’t have a good UI tool. It’s OK to login to cloudflare and upload images, but lazy as me I want to do it in a more convenient way. So I thought I could use its API to build a tool to do uploading and manangement. The solutions for this could be a web app or a desktop app. I prefer the former one because I can use it anywhere as long as I have a browser.
To build a web app, you can use framworks like react or vue, but I am not sure if I can build it in a short time. So I turned to streamlit again. It allows you to build a web app with only python and have a decent amount of built-in components.