Python的事件驅動并發框架:Pulsar
Pulsar是一個事件驅動的并發框架,有了pulsar,你可以寫出在不同進程或線程中運行一個或多個活動的異步服務器。
應用
附帶以下功能
- Socket服務器
- WSGI服務器
- JSON-RPC
- Web Sockets
- 任務隊列
- Shell
- 測試包
- django集成
示例
對所有請求都返回“Hello World!”作為響應
from pulsar.apps import wsgi
def hello(environ, start_response):
data = b'Hello World!\n'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len(data)))
]
start_response('200 OK', response_headers)
return [data]
if __name__ == '__main__':
wsgi.WSGIServer(callable=hello).start()
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!