V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  fanhaipeng0403  ›  全部回复第 13 页 / 共 27 页
回复总数  540
1 ... 9  10  11  12  13  14  15  16  17  18 ... 27  
SEO:
深圳市成为智能交通系统有限公司 怎么样
深圳市成为智能交通系统有限公司 薪资待遇
深圳市成为智能交通系统有限公司 拖欠工资
深圳市成为智能交通系统有限公司 好不好
深圳市成为智能交通系统有限公司 无赖公司
深圳市成为智能交通系统有限公司 招聘信息
深圳市成为智能交通系统有限公司 信用怎么样
深圳市成为智能交通系统有限公司 企业架构
深圳市成为智能交通系统有限公司 公司氛围
深圳市成为智能交通系统有限公司 福利
深圳市成为智能交通系统有限公司 产品介绍
深圳市成为智能交通系统有限公司 企业咨询
深圳市成为智能交通系统有限公司 产品口碑
2019-01-03 12:46:16 +08:00
回复了 fanhaipeng0403 创建的主题 Python 分享个 celery 的监控脚本吧
@zhoudaiyu 看了~我最近也要处理这个事情~
db.session.close()

每次都关掉,绝对会解决
2019-01-03 11:35:10 +08:00
回复了 0x11901 创建的主题 职场话题 关于自身技术发展的疑惑?
和我想的差不多·~
2019-01-03 11:24:14 +08:00
回复了 hauzi 创建的主题 程序员 各位大佬写代码的时候一般戴耳机么?听些什么呢?
2019-01-03 11:20:17 +08:00
回复了 YuuuZeee 创建的主题 Python Celery 可以启动多个线程嘛=-=
import asyncio

async def slow_operation(n):
await asyncio.sleep(n)
print('Slow operation {} complete'.format(n))
return n


loop = asyncio.get_event_loop()
done, _ = loop.run_until_complete(
asyncio.wait([
slow_operation(1),
slow_operation(2),
slow_operation(9),
slow_operation(2),
slow_operation(1),
slow_operation(2),
slow_operation(3),
]))
for fut in done:
print("return value is {}".format(fut.result()))

然后用 uvloop
2019-01-03 11:17:28 +08:00
回复了 YuuuZeee 创建的主题 Python Celery 可以启动多个线程嘛=-=
y worker -A app.tasks.celery -l INFO -Q default -c 20 (每个队列多搞几个 worker ) -n default_worker.%%i
2019-01-03 11:16:30 +08:00
回复了 YuuuZeee 创建的主题 Python Celery 可以启动多个线程嘛=-=
from time import sleep
from concurrent.futures import ThreadPoolExecutor\ ProcessPoolExecutor
def child_1():
sleep(9)
print(1)


def child_2():
sleep(2)
print(2)



def child_3():
sleep(3)
print(3)



def child_4():
sleep(1)
print(4)


def child_5():
sleep(2)
print(5)



with ThreadPoolExecutor\ProcessPoolExecutor(max_workers=5) as executor:
executor.submit(child_1)
executor.submit(child_2)
executor.submit(child_3)
executor.submit(child_4)
executor.submit(child_5)


t1= executor.submit(child_1)
t2=executor.submit(child_2)
t3=executor.submit(child_3)
t4=executor.submit(child_4)
t5=executor.submit(child_5)

print(t1.result())
2019-01-03 11:12:16 +08:00
回复了 0x8192dd 创建的主题 Android 发现很多人不理解各大渠道强制要求适配 API26+的意义
作死的头像
2019-01-03 11:09:39 +08:00
回复了 hahiru 创建的主题 职场话题 我再帮同事开发办公软件我就是狗。
销售 副业 写代码 ??? 6666
引起不适,block
2019-01-02 12:29:49 +08:00
回复了 karnaugh 创建的主题 程序员 大家对这种印着 api 的超大鼠标垫有兴趣么
有毛用,看还不如 google 快
2019-01-02 11:23:35 +08:00
回复了 daya0576 创建的主题 程序员 😍发现一个持续部署的好东西: Buddy
mark
2019-01-01 14:24:51 +08:00
回复了 zhoudaiyu 创建的主题 Python 问个问题,关于 Celery 的 worker 和 beat
@zhoudaiyu

可以使用 celery 提供的信号接口,监测每个任务的执行时间,然后发给 statsd 或者 promethus 之类的

https://github.com/getredash/redash/blob/master/redash/metrics/celery.py

这个是代码例子
2019-01-01 01:20:46 +08:00
回复了 daya0576 创建的主题 程序员 😍发现一个持续部署的好东西: Buddy
@mercury233 捞一波是一波
2019-01-01 01:19:45 +08:00
回复了 daya0576 创建的主题 程序员 😍发现一个持续部署的好东西: Buddy
插眼
2018-12-31 22:48:40 +08:00
回复了 fanhaipeng0403 创建的主题 Python 问大家一个关于 async 和 await 的问题, 新年快乐~
In [1]: import asyncio
...:
...: try:
...: # pylint: disable=invalid-name
...: asyncio_run = asyncio.run # type: ignore
...: except AttributeError:
...:
...: def asyncio_run(main, debug=False):
...: """Minimal re-implementation of asyncio.run (since 3.7)."""
...: loop = asyncio.new_event_loop()
...: asyncio.set_event_loop(loop)
...: loop.set_debug(debug)
...: try:
...: return loop.run_until_complete(main)
...: finally:
...: asyncio.set_event_loop(None)
...: loop.close()
...:
...: async def slow_operation_1(m):
...: await asyncio.sleep(m)
...: print('Slow operation {} complete'.format(m))
...: return m
...:
...:
...:
...: async def slow_operation_2(n):
...: await asyncio.sleep(n)
...: print('Slow operation {} complete'.format(n))
...:
...: return await slow_operation_1(m=n+1)
...:
...: result = asyncio_run(slow_operation_2(2))
...:
...: print(result)
...:

Slow operation 2 complete
Slow operation 3 complete
3
2018-12-29 22:17:00 +08:00
回复了 zhoudaiyu 创建的主题 Python 问个问题,关于 Celery 的 worker 和 beat
RabbitMQ is feature-complete, stable, durable and easy to install. It ’ s an excellent choice for a production environment.

官方文档推荐的~
@zhoudaiyu
2018-12-29 21:56:38 +08:00
回复了 zhoudaiyu 创建的主题 Python 问个问题,关于 Celery 的 worker 和 beat
建议用 rabittmq。
还算稳定,分享下我的配置



CELERY_IGNORE_RESULT = True
CELERY_BROKER_URL = '‘ xxxx ’
CELERY_TIMEZONE = 'xxx'
CELERY_DEFAULT_QUEUE = 'default'
CELERY_CREATE_MISSING_QUEUES = 'default'

BROKER_HEARTBEAT = 24*60*60*2

CELERY_ENABLE_UTC = False
CELERY_DISABLE_RATE_LIMITS = True
CELERYD_MAX_TASKS_PER_CHILD = 10
BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 1800}
CELERYD_FORCE_EXECV = True
BROKER_POOL_LIMIT = None
2018-12-29 11:45:51 +08:00
回复了 hackxing 创建的主题 职场话题 请假被拒了。。。。。。
今天打算把你顶上去,这么欢乐的事情居然发生在 2019 年
1 ... 9  10  11  12  13  14  15  16  17  18 ... 27  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2623 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 76ms · UTC 09:08 · PVG 17:08 · LAX 02:08 · JFK 05:08
Developed with CodeLauncher
♥ Do have faith in what you're doing.