Launching python within python and timezone issue
- by Gabi Purcaru
I had to make a launcher script for my django app, and it seems it somehow switches the timezone to GMT (default being +2), and every datetime is two hours behind when using the script. What could be causing that?
Here is the launcher script that I use:
#!/usr/bin/env python
import os
import subprocess
import shlex
import time
cwd = os.getcwd()
p1 = subprocess.Popen(shlex.split("python manage.py runserver"),
cwd=os.path.join(cwd, "drugsworld"))
p2 = subprocess.Popen(shlex.split("python coffee_auto_compiler.py"),
cwd=os.path.join(cwd))
try:
while True:
time.sleep(2)
except KeyboardInterrupt:
p1.terminate()
p2.terminate()
If I manually run python manage.py runserver, the timezone is +2. If, however, I use this script, the timezone is set to GMT.