1

我有一个仍然在 python2.5 运行时运行的 Appengine 应用程序,这意味着它是单线程的。我有一个学校课程:

class School(db.Model):
    ...
    dateformat=db.StringProperty(default='%a %e %b',indexed=False) # For bookings
    timeformat=db.StringProperty(default='%l:%M%P',indexed=False) # For bookings
    def date(self,t):
        return time.strftime(self.dateformat,time.gmtime(t))
    def datetime(self,bt,et=None):
        return time.strftime(self.dateformat+' '+self.timeformat,time.gmtime(bt))+\
                (time.strftime(' - '+self.timeformat,time.gmtime(et)) if et else '')
    def time(self,t):
        return time.strftime(self.timeformat,time.gmtime(t))

然后,当我想以学校选择的格式格式化日期时,我会这样做:

s=School.get_by_id(the_id)
date_string=s.date(the_timestamp)

非常偶尔,我得到一个正好是一周的约会。因此,我得到的不是“5 月 2 日星期三”,而是“5 月 9 日星期三”。在可能数万例中,上周已报告了 3 次。整整一个星期,没有任何其他时差。

多年来,我的代码的那部分没有任何变化,所以我不明白为什么会突然开始发生这种情况。因为它是单线程的,所以 strftime 不应该有问题,而且无论如何我都找不到任何关于它的线程问题的报告。

有任何想法吗?

4

0 回答 0