Skip to content

A tiny python asyncio just for learning πŸ™‹β€β™‚οΈ

Notifications You must be signed in to change notification settings

HFrost0/tiny-asyncio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

tiny-asyncio

A tiny python asyncio just for learning πŸ™‹β€β™‚οΈ, document below is my personal notes during the learning, may change frequently.

TCP Echo Servers

I implement a series of TCP echo server for the test of tiny-asyncio client including multi threading, IO multiplexing and so on. Details can be found here.

Event Loop

Event loop is just a while True loop, the basic functionality of event loop is to keep find out which functions can be executed and execute them. Event loop's implementation I think is not related to coroutine or generator, it's just a scheduler used to execute functions (even regardless their return value).

Task and Future

The core code in Future

def __await__(self):
    yield self


__iter__ = __await__

yield itself. and Task's __step will receive bottom future object, and add done callback to them. Notice that all function will be executed by a global event loop including __step. I think this part is the core part in asyncio.

yield from and await

What eventually block the program in python design is the yield, while yield from (await) just keep send None to generator (or we call coroutine) unless got a StopIteration, and

x = yield from coro

StopIteration's value will be assigned to x, notice that if we call return in generator or coroutine function it will raise a StopIteration.

Selectors

official python selectors module

todos

  • get_event_loop
  • selectors block
  • async sock
  • gather
  • exception handle, may with bug πŸ€”
  • creat server
  • cancel

quote

About

A tiny python asyncio just for learning πŸ™‹β€β™‚οΈ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages