I'm trying to make a simple web service which reads an MSEED file and outputs some information on that.
The most reasonable choice seemed to be using python with the excellent obspy module (A Python Toolbox for seismology/seismological observatories), which is widely used in the seismological community.
I succed in reading a file and getting some information from it with this simple python code:
import obspy
import numpy
import sys
my_filename = "SOME FILE"
my_start_time = "2012-01-01T08:00:00"
my_end_time = "2012-01-01T09:00:00"
dt = obspy.UTCDateTime(my_start_time)
et = obspy.UTCDateTime(my_end_time)
st = obspy.read(my_filename, starttime=dt, endtime=et)
....then do something....
Now, if I want to implement it as a web service, among the several different choiche I can install the mod_python on Apache, and invoke such script in a bit different way.
I do as follows (the script is in a file called test.py
):
from mod_python import util
import obspy
import numpy
import sys
def index(req):
[...]
startdate="2012-01-01T08:00:01"
enddate="2012-01-01T08:10:00"
myfilename=" SOME FILE"
dt = obspy.UTCDateTime(startdate)
et = obspy.UTCDateTime(enddate)
##### read file
st = obspy.read(my_filename, starttime=dt, endtime=et) ******
[...]
What happens is that on the last line it hangs without giving any error. when invoking the script from my server http://localhost.my/cgi-bin/test.py it works well until the last line, then after that it doesn't even print anything but, again WITHOUT OUTPUT ERRORS
Eveno more weird, if I change the last line with
st = obspy.read(my_filename, headonly=True)
then it works.
What I tried:
But it still doesn't work.
I don't understand if it is a problem of the obspy module or some limitation to the apache mod_python.
Any idea about how to solve this issue?
The best answer I received from obspy github issue page was the following
It seems to be related to a memory allocation issue. You could try to update to the latest ObsPy repository version as we recently made some changes to that and see if that resolves your issue. I am pretty sure that it is not a permissions related issue.
Otherwise, if you are not tied to using mod_python, you could try out one of the very many and oftentimes very good Python web frameworks. If you just need it for a simple webservice, a microframework might suit you well:
http://flask.pocoo.org/ http://www.pylonsproject.org/ http://www.cherrypy.org/ Of course Django might also appeal to you.
Cheers!