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
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:
from obspy.core import UTCDateTime
from obspy.seedlink.slpacket import SLPacket
from obspy.seedlink.client.seedlinkconnection import SeedLinkConnection
logger = logging.getLogger("dummy")
if len(sys.argv) != 2 or sys.argv not in ["pass","hang"]:
print " usage: python %s <pass|hang>" % (sys.argv)
slc = SeedLinkConnection(timeout=2)
if sys.argv == "pass":
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
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