lidavidm commented on code in PR #3810:
URL: https://github.com/apache/arrow-adbc/pull/3810#discussion_r2623804896
##########
python/adbc_driver_manager/adbc_driver_manager/dbapi.py:
##########
@@ -372,6 +378,11 @@ def close(self) -> None:
if self._closed:
return
+ # Close all open cursors first to avoid RuntimeError from
+ # AdbcConnection about open children
+ for cursor in list(self._cursors):
Review Comment:
nit: can't you iterate the WeakSet directly?
It appears the `list` guard is well out of date:
https://stackoverflow.com/questions/12428026/safely-iterating-over-weakkeydictionary-and-weakvaluedictionary
##########
python/adbc_driver_manager/adbc_driver_manager/dbapi.py:
##########
@@ -372,6 +378,11 @@ def close(self) -> None:
if self._closed:
return
+ # Close all open cursors first to avoid RuntimeError from
+ # AdbcConnection about open children
+ for cursor in list(self._cursors):
+ cursor.close()
Review Comment:
If `close` raises, the other references won't get closed. Can we handle
that? (We should catch `Exception` and either prepare to rethrow it, or add it
as a suppressed exception.)
For testing purposes, we could factor it out into a small internal helper
that can then be directly tested with non-Cursor objects containing a close
method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]