xumi1993 / bqmail

Python module for requesting seismic data to IRIS DMC
MIT License
10 stars 7 forks source link

http.client.IncompleteRead: IncompleteRead #2

Closed JandyZ22 closed 2 years ago

JandyZ22 commented 2 years ago

When I use bqmail to request data, I find that sometimes the following error is reported, but I'm not really sure how this error is caused, because after a while I use the same script to request data without reporting the error again.

Traceback (most recent call last): File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/http/client.py", line 576, in _readall_chunked value.append(self._safe_read(chunk_left)) File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/http/client.py", line 615, in _safe_read raise IncompleteRead(data, amt-len(data)) http.client.IncompleteRead: IncompleteRead(30 bytes read, 5 more expected)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "bqmailQIZ.py", line 26, in bq.query_events( File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/site-packages/bqmail/mail.py", line 85, in query_events self.query.get_events(**kwargs) File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/site-packages/bqmail/query.py", line 23, in get_events events = self.client.get_events(starttime=starttime, File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/site-packages/obspy/clients/fdsn/client.py", line 527, in get_events data_stream = self._download(url) File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/site-packages/obspy/clients/fdsn/client.py", line 1393, in _download code, data = download_url( File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/site-packages/obspy/clients/fdsn/client.py", line 1812, in download_url buf = io.BytesIO(url_obj.read()) File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/http/client.py", line 466, in read return self._readall_chunked() File "/home/ydz/miniconda3/envs/jandy/lib/python3.8/http/client.py", line 580, in _readall_chunked raise IncompleteRead(b''.join(value)) http.client.IncompleteRead: IncompleteRead(149807 bytes read)

xumi1993 commented 2 years ago

Could you provide your bqmailQIZ.py?

JandyZ22 commented 2 years ago

你能提供你的bqmailQIZ.py吗?

from bqmail.mail import BQMail
from obspy import UTCDateTime

bq = BQMail('******@qq.com', server='smtp.qq.com',
            password='********', username='QIZ1320JandyZ')

bq.query_stations(
    network='IC',
    loc='00',
    station='QIZ',
    channel='BH?')
#申请事件波形
bq.query_events(
    starttime=UTCDateTime(
        2013, 1, 10), endtime=UTCDateTime(
            2020, 9, 20), minmagnitude=5.0, latitude=19.0291, longitude=109.8445, minradius=30, maxradius=90, catalog='GCMT')

bq.send_mail(
    arrange='events',
    mark="P",
    time_before=-100,
    time_after=300,
)
xumi1993 commented 2 years ago

I also had this error before. As a similar issue reported by Obspy's users (https://github.com/obspy/obspy/issues/3028). I had fix this error in current version 2.1.3. Note that this version dosen't been uploaded to PyPI. Pls update the package to current version via source code and try angin.

https://github.com/xumi1993/bqmail/blob/f4b9dc41b3c4062d4ef7a8b5e7435e73a175988e/bqmail/query.py#L21

xumi1993 commented 2 years ago

Another solution is that you can narrow the scope of earthquakes. Such as setting up a larger minmagnitude.

JandyZ22 commented 2 years ago

Thanks for your reply.