datetime 8 hours off

23 views
Skip to first unread message

Simon Oberhammer

unread,
Apr 1, 2008, 4:46:49 AM4/1/08
to Django users
hey group,
I have an inconsistant time problem, which goes away when I restart
apache, but then creeps up again after some time. When writing
comments in my custom app the time is 8hours behind (i'm CEST) *for
some users*. When I login with others, its okay.

in settings.py I have
TIME_ZONE = 'Europe/Vienna'

simon@XXXXXX-162:~/pm3$ date
Tue Apr 1 10:44:32 CEST 2008

any ideas what I should look for? This is annyoing.. it forces my to
apache2ctl restart quite often :-)

greetings
simono

Ramiro Morales

unread,
Apr 1, 2008, 6:32:25 AM4/1/08
to django...@googlegroups.com

What version of Django are you using?, what deployment method
are you using? (mod_python, fast cgi, mod_wscgi).

--
Ramiro Morales

Simon Oberhammer

unread,
Apr 1, 2008, 3:15:04 PM4/1/08
to Django users

> What version of Django are you using?, what deployment method
> are you using? (mod_python, fast cgi, mod_wscgi).

i'm using mod_python and am running the current svn django. I've found
an open timezone bug, but don't think its related

http://code.djangoproject.com/changeset/7184

Simon Oberhammer

unread,
Apr 2, 2008, 8:03:38 AM4/2/08
to Django users
anybody? after restartign apache everything is fine again.. i have to
do this once or twice a day.

On Apr 1, 9:15 pm, Simon Oberhammer <simon.oberham...@gmail.com>
wrote:

Jarek Zgoda

unread,
Apr 2, 2008, 8:16:36 AM4/2/08
to django...@googlegroups.com
Simon Oberhammer napisał(a):

We had another problems with mod_python around year ago and we switched
to FastCGI. While not perfect, it does not give us any oddities like
race conditions coming from single-VM process (these times, mod_wsgi was
still maturing). May I suggest dropping mod_python and give mod_wsgi a try?

--
Jarek Zgoda
Skype: jzgoda | GTalk: zg...@jabber.aster.pl | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

Steven Armstrong

unread,
Apr 2, 2008, 8:19:54 AM4/2/08
to django...@googlegroups.com
Simon Oberhammer wrote on 04/01/08 10:46:

Is the time constantly 8 hours behind or does that vary e.g. does the
offset get larger over time?


Graham Dumpleton

unread,
Apr 2, 2008, 5:42:54 PM4/2/08
to Django users
On Apr 2, 10:16 pm, Jarek Zgoda <jarek.zg...@sensisoft.com> wrote:
> Simon Oberhammer napisał(a):
>
> > anybody? after restartign apache everything is fine again.. i have to
> > do this once or twice a day.
>
> > On Apr 1, 9:15 pm, Simon Oberhammer <simon.oberham...@gmail.com>
> > wrote:
> >>> What version of Django are you using?, what deployment method
> >>> are you using? (mod_python, fast cgi, mod_wscgi).
> >> i'm using mod_python and am running the current svn django. I've found
> >> an open timezone bug, but don't think its related
>
> >>http://code.djangoproject.com/changeset/7184
>
> We had another problems with mod_python around year ago and we switched
> to FastCGI. While not perfect, it does not give us any oddities like
> race conditions coming from single-VM process (these times,mod_wsgiwas
> still maturing). May I suggest dropping mod_python and givemod_wsgia try?

If using mod_wsgi, would suggest you use daemon mode (not embedded
mode) to isolate the application in its own processes. One of the
problems the OP may be having with mod_python is that the Apache child
processes are shared by other applications, such as PHP applications.
If they are running any PHP applications, maybe it is the PHP
application which is causing the problem by fiddling with underlying
TZ settings for the process. FastCGI would have avoided this sort of
problem as well because it also uses separate processes.

Graham

Simon Oberhammer

unread,
Apr 2, 2008, 8:58:01 PM4/2/08
to Django users
thanks, i will try fastcgi tomorrow and report back.

> Is the time constantly 8 hours behind or does that vary e.g. does the
> offset get larger over time?

it's always 8 hours behind, but not reproducable. though it happens
everyday.

there are php sites running on the server.. well let's see if fastcgi
helps.

David Reynolds

unread,
Apr 4, 2008, 8:04:10 AM4/4/08
to django...@googlegroups.com

Could this perhaps be that you are assigning datetime.now() (or
equivalent) to a variable and then trying to use this? Which means
that the value of that varible will be the date/time when apache is
started/restarted (which could be at the same time everyday).

Thanks,

David

--
David Reynolds
da...@reynoldsfamily.org.uk


Simon Oberhammer

unread,
Apr 4, 2008, 8:16:14 AM4/4/08
to Django users
Magus on IRC told me that multiple django projects with different
timezones serverd by apache / mod_python could be a problem - ie one
changing TZ in a thread that also servers the other project.

So I set timezone-setting to Vienna/Europe for all of them and have
not seen then datetime-problem since 24hours. I think that was it.

Andrew Durdin

unread,
Apr 22, 2008, 7:51:26 AM4/22/08
to Django users
On Apr 4, 1:16 pm, Simon Oberhammer <simon.oberham...@gmail.com>
wrote:
We were encountering the same problem, as one django project was still
set to 'America/Chicago' instead of 'Europe/London' which is where we
are. This appears to be a bug in the Django mod_python handler, so I
have added a ticket for it: http://code.djangoproject.com/ticket/7062

Andrew

Graham Dumpleton

unread,
Apr 22, 2008, 8:25:02 AM4/22/08
to Django users
Except that setting TZ on every request doesn't solve the problem and
may just make it worse for multithread Apache MPM modules such as used
on Windows, or worker MPM on UNIX.

The only safe way to run multiple Django instances with different
timezone settings is to run them in separate processes using mod_wsgi
daemon mode or fastcgi type solutions.

Graham

Sander Steffann

unread,
Apr 22, 2008, 11:43:12 AM4/22/08
to django...@googlegroups.com
Hi,

> The only safe way to run multiple Django instances with different
> timezone settings is to run them in separate processes using mod_wsgi
> daemon mode or fastcgi type solutions.

We are using runfcgi with protocol=ajp, with proxy_ajp on the Apache side.
Works great here.
Sander

Reply all
Reply to author
Forward
0 new messages