Member-only story

Greenletio: A helpful library to cooperate your synchronous and asynchronous functions

Kevin Tewouda
4 min readNov 20, 2023

--

Photo by Shane Rounce on Unsplash

With the advent of asynchronous in Python, I refer to asyncio, we sometimes find ourselves in situations where we would like to use an asynchronous library in an existing synchronous program. Except that coroutines are not made to work in the synchronous world. Well… that was before introducing you to the following library.😁

Greenletio solves this issue with a bit of magic using the greenlet library. So let’s see how it works.

Installation

To use Greenletio, we will need Python 3.7 or higher.

$ pip install greenletio
# or
$ poetry add greenletio

If you don’t know Poetry, I wrote an article on it here.

Usage

Suppose we have the following asynchronous function fetching information for the Star Wars characters. We use the httpx library for fetching. By the way, I recommend you check this library if you don’t know it.

async def fetch_user(name: str) ->…

--

--

Kevin Tewouda
Kevin Tewouda

Written by Kevin Tewouda

Déserteur camerounais résidant désormais en France. Passionné de programmation, sport, de cinéma et mangas. J’écris en français et en anglais dû à mes origines.

No responses yet