V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  messense  ›  全部回复第 3 页 / 共 26 页
回复总数  515
1  2  3  4  5  6  7  8  9  10 ... 26  
2017-06-11 23:40:15 +08:00
回复了 resolvewang 创建的主题 问与答 aiohttp 怎么复用连接池
aiomysql.create_pool 需要 await 吧?没有 await 它返回的是个 coroutine,试试:

self.pool = self.loop.run_until_complete(aiomysql.create_pool(...))
2017-06-11 21:18:32 +08:00
回复了 resolvewang 创建的主题 问与答 aiohttp 怎么复用连接池
把 pool 放到 main 里面?

import aiomysql
import asyncio


async def select(pool, sql):
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute(sql)
r = await cur.fetchone()
print(r)


async def insert(pool, sql):
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute(sql)
await conn.commit()


async def main(loop):
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='123456',
db='test', loop=loop)
c1 = select(pool, sql='select * from minifw')
c2 = insert(pool, sql="insert into minifw (name) values ('hello')")
tasks = [
asyncio.ensure_future(c1),
asyncio.ensure_future(c2)
]
return await asyncio.gather(*tasks)

if __name__ == '__main__':
cur_loop = asyncio.get_event_loop()
cur_loop.run_until_complete(main(cur_loop))
2017-05-06 22:46:16 +08:00
回复了 cxz 创建的主题 Python 2017 年 5 月的现在,还有什么理由不使用 Python 3?
2017-05-03 10:34:50 +08:00
回复了 zhangwb2008 创建的主题 macOS [VANILLA] Hide menu bar icons on your Mac
2017-04-24 22:37:20 +08:00
回复了 sadhen 创建的主题 Python 几乎所有的同事都不支持用 python3 哎
公司最主要的项目已经在使用 Python 3.6 了。
2017-03-24 11:24:44 +08:00
回复了 chztv 创建的主题 macOS Setapp 可以继续免费用了,发邀请了!
2017-03-22 21:12:13 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@guyskk #9 ORM 支持不咋的,有在生产环境使用,一个并不涉及到数据库的项目:

https://github.com/bosondata/prerender
2017-03-21 10:51:30 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@freestyle #7 并不是同步跑 WSGI ,自定义 gunicorn worker 跑 asyncio event loop
2017-03-20 20:26:41 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@cheetah aiohttp 2.0 也废弃了 WSGI 支持,估计以后 gaiohttp 也没法用了。

http://aiohttp.readthedocs.io/en/latest/migration.html#wsgi
2017-03-20 20:18:16 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@cheetah #4 actually ,即便实现了 __call__ 也不好继续下去,因为 Sanic 并不兼容 WSGI , gunicorn 的 gaiohttp worker 是基于 WSGI 的
2017-03-20 20:15:07 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@cheetah 根本起不来

gunicorn simple_server:app --bind localhost:8000 --worker-class gaiohttp --capture-output
[2017-03-20 20:13:34 +0800] [3226] [INFO] Starting gunicorn 19.6.0
[2017-03-20 20:13:34 +0800] [3226] [INFO] Listening at: http://127.0.0.1:8000 (3226)
[2017-03-20 20:13:34 +0800] [3226] [INFO] Using worker: gaiohttp
[2017-03-20 20:13:34 +0800] [3260] [INFO] Booting worker with pid: 3260
Application object must be callable.
[2017-03-20 20:13:34 +0800] [3260] [INFO] Worker exiting (pid: 3260)
[2017-03-20 20:13:34 +0800] [3226] [INFO] Shutting down: Master
[2017-03-20 20:13:34 +0800] [3226] [INFO] Reason: App failed to load.

也需要一些 hack ,比如类似: https://github.com/messense/sanic-gunicorn/commit/e60a683f976cd66a36f3c1ee88b92f4be190067a#diff-757823b0d65a4f88a48899c3fd4135c8R54

或者自己实现下 __call__
2017-03-20 19:27:58 +08:00
回复了 messense 创建的主题 Python Gunicorn worker for Sanic
@cheetah 好像 aiohttp 的速度不够快啊,不过我也没试……待验证。
2017-03-12 15:06:04 +08:00
回复了 cloudyplain 创建的主题 Python Python 多线程死锁
2017-03-02 22:57:00 +08:00
回复了 lucat 创建的主题 求职 [上海/杭州] 应聘 Python 工程师,一个有想法的应届生
2017-02-27 18:08:08 +08:00
回复了 lgpqdwjh 创建的主题 Flask 关于 flask json data 校验
JSON Schema
2017-02-27 09:47:49 +08:00
回复了 SlipStupig 创建的主题 Python tornado 貌似 4.5+考虑放弃维护 Python 2.x 了
@killpanda 目前发现的两个问题:

1. 它自己的 logging 用得不太对
2. 请求出现异常的时候 request 对象可能是 None ,日志会非常难 debug
2017-02-26 22:45:13 +08:00
回复了 MasterMonkey 创建的主题 Python 大家有用自动化集成系统的吗?
感觉 buildbot 太复杂了,造了个轮子: https://github.com/bosondata/badwolf
2017-02-26 22:42:58 +08:00
回复了 4ever911 创建的主题 Python 同步调用等待的代码修改成异步执行
1  2  3  4  5  6  7  8  9  10 ... 26  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5737 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 98ms · UTC 03:04 · PVG 11:04 · LAX 20:04 · JFK 23:04
Developed with CodeLauncher
♥ Do have faith in what you're doing.