V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  fanhaipeng0403  ›  全部回复第 13 页 / 共 28 页
回复总数  547
1 ... 9  10  11  12  13  14  15  16  17  18 ... 28  
2019-01-05 21:06:04 +08:00
回复了 simoncos 创建的主题 Python Python 功能点实现:函数级/代码块级计时器
卧槽 我刚写了个类似的文章~
2019-01-05 01:18:14 +08:00
回复了 smallgoogle 创建的主题 Python Linux 下 multiprocessing 的结束子进程问题
```
class CountdownTask:
def __init__(self):
self._running = True

def terminate(self):
self._running = False

def run(self, n):
while self._running and n > 0:
print('T-minus', n)
n -= 1
time.sleep(5)

c = CountdownTask()
t = Thread(target=c.run, args=(10,))
t.start()
c.terminate() # Signal termination
t.join() # Wait for actual termination (if needed)
```
2019-01-05 01:17:40 +08:00
回复了 smallgoogle 创建的主题 Python Linux 下 multiprocessing 的结束子进程问题
t.daeman =true
老大做完,小弟就不做了

t.join()
老大等小弟做完继续在做


class CountdownTask:
def __init__(self):
self._running = True

def terminate(self):
self._running = False

def run(self, n):
while self._running and n > 0:
print('T-minus', n)
n -= 1
time.sleep(5)

c = CountdownTask()
t = multiprocessing.Process(target=c.run, args=(10,))
t.start()
c.terminate() # Signal termination
t.join() # Wait for actual termination (if needed)
老大给小弟给信号



不知道理解的对不对、、、
ipython manage.py shell

%debug
2019-01-04 15:52:44 +08:00
回复了 zhangqilin 创建的主题 职场话题 后端工作 1 年 2 个月感慨
@liprais 不大么~
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
1 ... 9  10  11  12  13  14  15  16  17  18 ... 28  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4554 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 36ms · UTC 01:06 · PVG 09:06 · LAX 18:06 · JFK 21:06
Developed with CodeLauncher
♥ Do have faith in what you're doing.