diff --git a/trino/dbapi.py b/trino/dbapi.py index 62ce893b..47130dab 100644 --- a/trino/dbapi.py +++ b/trino/dbapi.py @@ -706,7 +706,8 @@ def cancel(self): self._query.cancel() def close(self): - self.cancel() + if self._query is not None: + self.cancel() # TODO: Cancel not only the last query executed on this cursor # but also any other outstanding queries executed through this cursor.