简体   繁体   English

定制服务器python的asyncio vs asyncore

[英]asyncio vs asyncore for custom server python

我想为某个项目构建自定义服务器,但我不知道asyncoreasyncio服务器之间的区别什么什么更好用,以及为什么

asyncore is the "old", Python 2 way of doing some basic event-driven servers and clients (in other words, for doing asynchronous IO). asyncore是Python 2的“古老”方式,用于处理一些基本的事件驱动的服务器和客户端(换句话说,用于异步IO)。

asyncio is the new, Python 3 module that provides a whole framework for doing asynchronous IO in general. asyncio是新的Python 3模块,它提供了一个整体框架来执行异步IO。 It has much more features, including support for coroutines, which allow you to use keywords like async def and await , which improve readability of asynchronous code. 它具有更多功能,包括对协程的支持,该协程允许您使用诸如async defawait类的关键字,从而提高了异步代码的可读性。

In summary, asyncio is the way to go. 总而言之, asyncio是必经之路。 asyncore is not recommended in Python 3, which new projects should be using instead of Python 2. If you are stuck with Python 2, asyncore is a sane choice. 在Python 3中不建议使用asyncore而不是在使用新项目,而应使用Python2。如果您对Python 2感到asyncore ,那么asyncore是明智的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM