diff --git a/lbry/dht/blob_announcer.py b/lbry/dht/blob_announcer.py index f1194e8c5..46c74de4c 100644 --- a/lbry/dht/blob_announcer.py +++ b/lbry/dht/blob_announcer.py @@ -42,8 +42,6 @@ class BlobAnnouncer: log.debug("failed to announce %s, could only find %d peers, retrying soon.", blob_hash[:8], peers) except Exception as err: self.announcements_sent_metric.labels(peers=0, error=True).inc() - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise err log.warning("error announcing %s: %s", blob_hash[:8], str(err)) async def _announce(self, batch_size: typing.Optional[int] = 10): diff --git a/lbry/extras/daemon/components.py b/lbry/extras/daemon/components.py index 1e5e6a445..5cce7d42c 100644 --- a/lbry/extras/daemon/components.py +++ b/lbry/extras/daemon/components.py @@ -560,8 +560,6 @@ class UPnPComponent(Component): self.upnp = await UPnP.discover(loop=self.component_manager.loop) log.info("found upnp gateway: %s", self.upnp.gateway.manufacturer_string) except Exception as err: - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise log.warning("upnp discovery failed: %s", err) self.upnp = None diff --git a/lbry/file/file_manager.py b/lbry/file/file_manager.py index 67c1630d7..ff2b8dff0 100644 --- a/lbry/file/file_manager.py +++ b/lbry/file/file_manager.py @@ -98,8 +98,6 @@ class FileManager: except asyncio.TimeoutError: raise ResolveTimeoutError(uri) except Exception as err: - if isinstance(err, asyncio.CancelledError): - raise log.exception("Unexpected error resolving stream:") raise ResolveError(f"Unexpected error resolving stream: {str(err)}") if 'error' in resolved_result: @@ -245,7 +243,7 @@ class FileManager: except asyncio.TimeoutError: error = DownloadDataTimeoutError(stream.sd_hash) raise error - except Exception as err: # forgive data timeout, don't delete stream + except (Exception, asyncio.CancelledError) as err: # forgive data timeout, don't delete stream expected = (DownloadSDTimeoutError, DownloadDataTimeoutError, InsufficientFundsError, KeyFeeAboveMaxAllowedError, ResolveError, InvalidStreamURLError) if isinstance(err, expected): diff --git a/lbry/stream/managed_stream.py b/lbry/stream/managed_stream.py index 6f12bb63f..9eef858e9 100644 --- a/lbry/stream/managed_stream.py +++ b/lbry/stream/managed_stream.py @@ -366,7 +366,7 @@ class ManagedStream(ManagedDownloadSource): return sent except ConnectionError: return sent - except (OSError, Exception) as err: + except (OSError, Exception, asyncio.CancelledError) as err: if isinstance(err, asyncio.CancelledError): log.warning("stopped uploading %s#%s to reflector", self.claim_name, self.claim_id) elif isinstance(err, OSError): diff --git a/lbry/torrent/session.py b/lbry/torrent/session.py index 713d82039..d1b118e8c 100644 --- a/lbry/torrent/session.py +++ b/lbry/torrent/session.py @@ -22,9 +22,9 @@ class TorrentHandle: self._loop = loop self._executor = executor self._handle: libtorrent.torrent_handle = handle - self.started = asyncio.Event(loop=loop) - self.finished = asyncio.Event(loop=loop) - self.metadata_completed = asyncio.Event(loop=loop) + self.started = asyncio.Event() + self.finished = asyncio.Event() + self.metadata_completed = asyncio.Event() self.size = 0 self.total_wanted_done = 0 self.name = '' diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 42499d2c6..3bd3b8d24 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -939,8 +939,6 @@ class Ledger(metaclass=LedgerRegistry): account.id, balance, total_receiving, account.receiving.gap, total_change, account.change.gap, channel_count, len(account.channel_keys), claim_count) except Exception as err: - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise log.exception( 'Failed to display wallet state, please file issue ' 'for this bug along with the traceback you see below:') @@ -964,8 +962,6 @@ class Ledger(metaclass=LedgerRegistry): try: resolved, _, _, _ = await self.claim_search([], claim_ids=claim_ids) except Exception as err: - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise log.exception("Resolve failed while looking up purchased claim ids:") resolved = [] lookup = {claim.claim_id: claim for claim in resolved} @@ -1046,8 +1042,6 @@ class Ledger(metaclass=LedgerRegistry): try: resolve_results, _, _, _ = await self.claim_search([], claim_ids=claim_ids) except Exception as err: - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise log.exception("Resolve failed while looking up collection claim ids:") return [] claims = [] diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 55b8b145b..18804608f 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -117,7 +117,7 @@ class ClientSession(BaseClientSession): ) else: await asyncio.sleep(max(0, max_idle - (now - self.last_send))) - except Exception as err: + except (Exception, asyncio.CancelledError) as err: if isinstance(err, asyncio.CancelledError): log.info("closing connection to %s:%i", *self.server) else: diff --git a/setup.py b/setup.py index fc834d26f..e71b38ebe 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ setup( long_description_content_type="text/markdown", keywords="lbry protocol media", license='MIT', - python_requires='>=3.7', + python_requires='==3.9.*', packages=find_packages(exclude=('tests',)), zip_safe=False, entry_points={ diff --git a/tests/unit/stream/test_stream_manager.py b/tests/unit/stream/test_stream_manager.py index ba6d8dbc8..a3a84206c 100644 --- a/tests/unit/stream/test_stream_manager.py +++ b/tests/unit/stream/test_stream_manager.py @@ -340,8 +340,6 @@ class TestStreamManager(BlobExchangeTestBase): try: await self.file_manager.download_from_uri(self.uri, self.exchange_rate_manager, timeout) except Exception as err: - if isinstance(err, asyncio.CancelledError): # TODO: remove when updated to 3.8 - raise error = err self.assertEqual(expected_error, type(error))