Hi all
Q: How do I get SeedLinkConnection.collect() to timeout as indicated to be possible in the online docs
I'm trying to get the obspy seedlink client to timeout but so far no avail. At least according to the documentation of ObsPy it is indicated that this is possible
(see https://docs.obspy.org/packages/autogen/obspy.seedlink.client.seedlinkconnection.SeedLinkConnection.collect.html#obspy.seedlink.client.seedlinkconnection.SeedLinkConnection.collect)
so chances are that I'm simply doing something stupid (ergo any pointers are appreciated)
I've narrowed the problem down as far as possible (hence the code below is only intended to illustrate the problem) to the following script:
#! /usr/bin/env
import sys,time,logging
from obspy.core import UTCDateTime
from obspy.seedlink.slpacket import SLPacket
from obspy.seedlink.client.seedlinkconnection import SeedLinkConnection
logger = logging.getLogger("dummy")
logging.basicConfig(level=logging.DEBUG)
logger.setLevel(logging.DEBUG)
if len(sys.argv) != 2 or sys.argv[1] not in ["pass","hang"]:
print " usage: python %s <pass|hang>" % (sys.argv[0])
sys.exit()
slc = SeedLinkConnection(timeout=2)
slc.setSLAddress("rtserver.ipgp.fr:18000")
slc.setBeginTime(UTCDateTime(time.time()-360).formatSeedLink())
if sys.argv[1] == "pass":
slc.parseStreamlist("G_AIS:BHE",None)
else:
slc.parseStreamlist("WI_ABD:HHE",None)
slc.collect()
print " --- passed collect()"
If run as with input parameters "pass" all is well (this is implemented to demonstrate that data can be retrieved from the server).
If run with input parameter "hang" the seedlink server will be requested for data not supplied by the server. Naively I would expect for the server to simply return that no data is available which doesn't seem happen so as a backup I would expect (from the documentation) the script to timeout after two seconds which just doesn't happen.
killing the script with ctrl+C indicates that the process hangs at:
File "[...]/obspy/seedlink/client/seedlinkconnection.py", line 981, in collect
self.sladdr)
File "[...]/obspy/seedlink/client/seedlinkconnection.py", line 1218, in receiveData
bytesread = self.socket.recv(maxbytes)
Indicating that the script is awaiting some message from the server
regP