3 ms·
Unless you're performing some magic elsewhere in the codebase, this will leak connections if an exception is thrown since you're not closing the connection in a
by diek 8y ago
Unless you're performing some magic elsewhere in the codebase, this will leak connections if an exception is thrown since you're not closing the connection in a 'finally' block. Alternatively, depending on your version of Python, you could use a 'with' context to ensure the connection is closed.
- acutesoftware 8y agoGood point, thanks for that - there is a lot error handling I haven't shown but hadn't taken into account memory leaks.