http://www.chengweiyang.cn/gitbook/index.html
gitbook简明教程
Leave a reply
http://www.chengweiyang.cn/gitbook/index.html
用过MySQL的应该都知道,MySQL默认长链接只能保持8小时,超过后就会自动断开。
在peewee中如何维持长连接呢?
解决方法比较晦涩,需要自定义一个支持重试的mixin,然后自定义一种RetryMySQLDatabase混入mixin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from peewee import * from peewee import __exception_wrapper__ class RetryOperationalError(object): def execute_sql(self, sql, params=None, commit=True): try: cursor = super(RetryOperationalError, self).execute_sql( sql, params, commit) except OperationalError: if not self.is_closed(): self.close() with __exception_wrapper__: cursor = self.cursor() cursor.execute(sql, params or ()) if commit and not self.in_transaction(): self.commit() return cursor class RetryMySQLDatabase(RetryOperationalError, MySQLDatabase): pass |
之后当作MySQLDatabase正常使用就可以了
1 2 3 4 5 6 |
XXX_DB = RetryMySQLDatabase( 'dbname', host=MYSQL_HOST, port=MYSQL_PORT, user='user', passwd='pass') |
在sb中,支持多种定时执行模式(cron, fixRate, fixDelay),开启也非常简单:
1、在Application或者其他Autoconfig上
1 |
@EnableScheduling |
2、在需要定时执行的函数上
1 2 |
@Scheduled(fixedDelayString = "${config.timeInMs}") @Scheduled(cron = "${config.cronStr}") |
不过这里有个小坑,默认这个schedule只使用一个线程。
如果你在多个函数上使用了@Scheduled,那么一定是一个执行完毕,才能排下一个。这往往不是我们想[……]
https://improvmx.com/
自己改一下dns,就可以把邮件转发到你的已有邮箱。都不需要自己搭建邮件服务器了。。。
1 2 3 4 5 6 7 8 9 10 11 |
review() { branchName=`git rev-parse --abbrev-ref HEAD` branchAndTopic="${branchName}" echo "$1 is "$1 if [ -n $1 ]; then branchAndTopic="${branchName}""/"$1 fi git push origin HEAD:refs/for/${branchAndTopic}%r=xx1@yy.com,r=xx2@yy.com } |
主要是自动选择了分支,防止push错