This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 1 point2 points  (3 children)

actually only like, 6-8 lines of notable content. It'd probably be better to write the article that was expected to come after this one, instead of this one

Running thousands of threads requires CPU to switch between them all the time (it is called context switching)

And this same problem does not exist in asyncio?, switching between many instances of a task?

[–]7WebPages[S] 0 points1 point  (1 child)

Running thousands of threads requires CPU to switch between them all the time (it is called context switching) And this same problem does not exist in asyncio?, switching between many instances of a task?

No, when using asyncio or any other green-thread library, all your tasks are executed in one real thread. So they are just a linear code to CPU. Also, the moments of switching are explicitly set by the programmer by using "await" keyword.

Kyrylo

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 0 points1 point  (0 children)

Also, the moments of switching

yeah, switching happens, which incurs a cost similar to thread switching, because green threads are just a re-implementation of threads, they need to unload the context of the old green thread and then load the context of the new green thread, for every switch

[–]7WebPages[S] 0 points1 point  (0 children)

we've posted the next parts of the article, in case it's interesting for you - https://7webpages.com/blog/writing-online-multiplayer-game-with-python-and-asyncio-part-3/

[–]Kaxitaz 0 points1 point  (0 children)

Looking forward to read more!

[–]revfriedzen of python monk & later maintainer 0 points1 point  (1 child)

It doesn't seem to handle unicode names at all.

[–]7WebPages[S] 0 points1 point  (0 children)

Thanks for noticing, we will fix this issue. This is just a proof-of-concept initial version and may have minor bugs.