![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
To be TestHacker
知难行易,知易行难
展开
-
apscheduler 实现mongoDB作业存储
初始化配置from apscheduler.schedulers.background import BackgroundSchedulerfrom apscheduler.jobstores.mongodb import MongoDBJobStore, MongoClientfrom apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutorfrom conf import configjobstores原创 2021-12-13 21:51:32 · 1188 阅读 · 0 评论 -
Python列表推导和map/filter/lambda
如何写出pythonic的代码,让代码显得高大上?有很多应用场景需要用到python去过滤或者加工集合中的数据,自然会用到列表推导或者lambda表达式#过滤数组中模2为0的数|采用列表推导a = [x for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] if x % 2 == 1]#过滤数组中模2为0的数|采用map/filter/lambdas = list(filter(lambda n: n % 2 == 1, [1, 2, 3, 4, 5, 6, 7, 8,原创 2021-11-13 16:32:54 · 542 阅读 · 0 评论 -
Python单例模式解决flask_apscheduler运行两次问题
背景最近在搭建公司的自动化测试平台,有一个需求是定时执行某些自动化任务,自然需要引入一个定时任务框架。因为平台使用的是flask搭建的,自然而然的就会想到用flask_apscheduler。在引入flask_apscheduler框架后,发现每次定时任务均会执行两次,因此对该问题进行了百度/bing,网上大部分解决方案是:在app.run()中设置use_reloader=False,这样就可以避免函数被执行两次,采用上诉方案将代码部署到服务器上之后依旧会执行两次,最后继续百度尝试,发现采用单例模式可以原创 2021-11-07 14:26:15 · 2505 阅读 · 3 评论