Asynchronous execution of synchronous functions
Axy
axy at declassed.art
Mon Sep 26 14:18:27 EDT 2022
> Did you check the ThreadPoolExecutor or the ProcessPoolExecutor? They
> won't give you atomic writes unless you add a Lock or a Condition, but
> they will execute your code in another thread or process.
Yes, I did, but they are too complicated to use. I'd like something for
humans, such as
asynchronizer = InThreadExecutor()
result = await asynchronizer.run(myfunc, myargs, mykwargs)
and I almost implemented that borrowing code from asyncsqlite (doves fly
slowly, electric mail is even slower :)), but...
> Keep in mind that Python's threads have a global interpreter lock
> (GIL) that prevents full parallelism. Processes work as expected, but
> require IPC and pickable objects in and out.
yes, that became a problem.
So, I revoke my question. Went out to redesign the whole approach.
Thanks for reply!
Axy.
More information about the Python-list
mailing list