Skip to content

Instantly share code, notes, and snippets.

View ashu-tosh-kumar's full-sized avatar
:octocat:

Ashutosh ashu-tosh-kumar

:octocat:
View GitHub Profile
@ashu-tosh-kumar
ashu-tosh-kumar / sync_in_async.py
Created July 31, 2023 15:26
Call a synchronous function asynchronously in Python
# Assuming asyncio event loop. Import respective library if using any other event loop library
import asyncio
import functools
import time
from concurrent.futures.process import ProcessPoolExecutor
# Create a process pool executor to run sync function in awaitable process
executor = ProcessPoolExecutor()