asynchronous programming in python

What you describe (the main program flow resuming immediately while another function executes) is not what’s normally called “asynchronous” (AKA “event-driven”) programming, but rather “multitasking” (AKA “multithreading” or “multiprocessing”). You can get what you described with the standard library modules threading and multiprocessing (the latter allows actual concurrent execution on multi-core machines).

Asynchronous (event-driven) programming is supported in the standard Python library in the asyncore and asynchat modules, which are very oriented to networking tasks (indeed they internally use the select module, which, on Windows, only supports sockets — though on Unixy OSs it can also support any file descriptor).

For a more general (though also mostly networking oriented, but not limited to that) support for asynchronous (event-driven) programming, check out the twisted third-party package.

Leave a Comment