gcdsss 最近的时间轴更新
gcdsss

gcdsss

V2EX 第 648152 号会员,加入于 2023-09-12 15:22:53 +08:00
今日活跃度排名 11390
gcdsss 最近回复了
我踩过坑,解决方法,写一个多线程兼容的 handler 去处理

`
class MultiCompatibleTimedRotatingFileHandler(TimedRotatingFileHandler):
def doRollover(self):
if self.stream:
self.stream.close()
self.stream = None
# get the time that this sequence started at and make it a TimeTuple
currentTime = int(time.time())
dstNow = time.localtime(currentTime)[-1]
t = self.rolloverAt - self.interval
if self.utc:
timeTuple = time.gmtime(t)
else:
timeTuple = time.localtime(t)
dstThen = timeTuple[-1]
if dstNow != dstThen:
if dstNow:
addend = 3600
else:
addend = -3600
timeTuple = time.localtime(t + addend)
dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
# 兼容多进程并发 LOG_ROTATE
if not os.path.exists(dfn):
f = open(self.baseFilename, "a")
fcntl.lockf(f.fileno(), fcntl.LOCK_EX)
if not os.path.exists(dfn):
os.rename(self.baseFilename, dfn) # 释放锁 释放老 log 句柄
f.close()
if self.backupCount > 0:
for s in self.getFilesToDelete():
os.remove(s)
if not self.delay:
self.stream = self._open()
newRolloverAt = self.computeRollover(currentTime)
while newRolloverAt <= currentTime:
newRolloverAt = newRolloverAt + self.interval
# If DST changes and midnight or weekly rollover, adjust for this.
if (self.when == "MIDNIGHT" or self.when.startswith("W")) and not self.utc:
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover:
if (
not dstNow
): # DST kicks in before next rollover, so we need to deduct an hour
addend = -3600
else: # DST bows out before next rollover, so we need to add an hour
addend = 3600
newRolloverAt += addend
self.rolloverAt = newRolloverAt
`
自己调节,没有谁有义务去承受你的负能量,伴侣如果不理解你的话也没法,自己想办法去调节吧
60 天前
回复了 Jaie 创建的主题 Local LLM mac 有什么方案本地跑 ai 字幕
为啥我这跑起来识别不出来英文 CastingWords
同配置 9950x, x870, 4080s,上周刚配的,水冷随便压,最新的 bios 和 win11 ccd 延迟小了很多,基本不存在延迟的问题了
84 天前
回复了 rivercherdeeeeee 创建的主题 路由器 2024 路由器推荐(稳定性很重要)
我当初买了个 ax6s 刷了 op, 容量小的可怜,也不稳定,差不多用了一年多忍不了了直接一步到位上 n1000, 虚拟机 op 稳得一批
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2704 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 05:12 · PVG 13:12 · LAX 21:12 · JFK 00:12
Developed with CodeLauncher
♥ Do have faith in what you're doing.