lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.19k stars 483 forks source link

On shutdown - exchange rate manager: Expecting value: line 1 column 1 (char 0) #2168

Closed tzarebczan closed 2 years ago

tzarebczan commented 5 years ago

The Issue

@jackrobison and I saw this recently when shutting down sometimes.

Task exception was never retrieved
future: <Task finished coro=<BlobServerProtocol.handle_request() done, defined at c:\users\thoma\documents\lbry\lbrynet\blob_exchange\server.py:35> exception=ValueError('seek of closed file')>
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 1086, in _sendfile_fallback
    read = file.readinto(view)
ValueError: I/O operation on closed file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\thoma\documents\lbry\lbrynet\blob_exchange\server.py", line 62, in handle_request
    sent = await blob.sendfile(self)
  File "c:\users\thoma\documents\lbry\lbrynet\blob\blob_file.py", line 166, in sendfile
    return await self.loop.sendfile(writer.transport, handle, count=self.get_length())
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 1066, in sendfile
    offset, count)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 1094, in _sendfile_fallback
    file.seek(offset + total_sent)
ValueError: seek of closed file
2019-05-23 09:09:54,003 INFO     lbrynet.extras.daemon.exchange_rate_manager:217: Stopping exchange rate manager
Task exception was never retrieved
future: <Task finished coro=<MarketFeed._update_price() done, defined at c:\users\thoma\documents\lbry\lbrynet\extras\daemon\exchange_rate_manager.py:78> exception=JSONDecodeError('Expecting value: line 1 column 1 (char 0)')>
Traceback (most recent call last):
  File "c:\users\thoma\documents\lbry\lbrynet\extras\daemon\exchange_rate_manager.py", line 82, in _update_price
    self._save_price(self._subtract_fee(self._handle_response(response)))
  File "c:\users\thoma\documents\lbry\lbrynet\extras\daemon\exchange_rate_manager.py", line 133, in _handle_response
    json_response = json.loads(response)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Suggested Next Steps

Refactor the exchange rate code so that you can call the exchange rate _update_price from a unit test and pass it the valid and then invalid JSON to test that it properly handles those cases.

mirgee commented 5 years ago

I will take this up.

belikor commented 3 years ago

The pull request #2536 solved this issue, so I guess this issue can be closed.

jahway603 commented 2 years ago

@moodyjon & @eukreign appears this issue can be closed as PR https://github.com/lbryio/lbry-sdk/pull/2536 fixed it. Happy #Hacktoberfest

moodyjon commented 2 years ago

Closed as fixed by #2536.