DEV Community

Discussion on: Async programming in Python with asyncio

Collapse
 
daolf profile image
Pierre • Edited

Hello and thanks for this great article.

Just one remark about multithreading though.
Each of Python threads will not execute line 2 at the same time. But something like this can happen:
thread 1 execute line 2 -> thread 2 execute line 2 -> thread 1 execute line 3 -> thread 2 execute line 3 !!! (size overflow)
Race condition.

Because of the GIL (Global Interpreter Lock) no line of Python can be executed at the same time when doing multithreading.

Collapse
 
welldone2094 profile image
Andrea Benfatti

That's totally true. I didn't talk about it because it wasn't the main topic. Anyway on this subject you can use Processes instead of thread which don't suffer from GIL but i think they bring some overhead with them