shownb / shownb.github.com

shownb.github.io
shownb.github.io
5 stars 1 forks source link

踩坑sanic #10

Open shownb opened 6 years ago

shownb commented 6 years ago

安装 sudo apt-get install python3-dev wget https://bootstrap.pypa.io/get-pip.py python3 get-pip.py python3 -m pip install sanic

https://github.com/channelcat/sanic/wiki/Examples#jinja https://github.com/channelcat/sanic/issues/113

安装mysqldb apt-get install python-dev apt-get install libmysqlclient-dev #不然会提示mysql_config not found pip install mysql-python

pip install virtualenv

关掉app = Sanic(log_config=None) sanic一个bug 查看 sanic 的代码 633 行和 648 行,即使 log_config 在 run 设置了 False 或者 None 最后他还是用回了 self.log_config。即是 Sanic init的时候 的 log_config=LOGGING

python并发3:使用asyncio编写服务器 https://segmentfault.com/a/1190000010009295 基于协程、异步IO的python爬虫 https://ayonel.me/index.php/2017/05/17/coroutine_spider/ Python黑魔法 --- 异步IO( asyncio) 协程 http://www.jianshu.com/p/b5e347b3a17c

首先,你应该谨慎使用协程,只有在涉及到IO的时候,使用才是合理的。我不理解为什么parse, extract_link这种显然非阻塞的程序,你要用生成器。生成器并不是多进程,不是你写成协程的形式,速度就蹭蹭蹭上去的。而且大量无意义的协程跳来跳去,并不比回调的CallBack Hell好多少。你在Debug的时候,还是不能完全知道事情发生的先后顺序。链接:https://www.zhihu.com/question/38165027/answer/75155613