datajoint-python
datajoint-python copied to clipboard
Python context manager raises error with datajoint connection object
trafficstars
Bug Report
Description
Datajoint connection cannot be defined with the python with, and using with is the regular way to make sure a connection is closed after dj.conn().
Reproducibility
Include:
- OS (Linux)
- Python Version 3.9
- MySQL Version 8.0
- MySQL Deployment Strategy (remote)
- DataJoint Version 0.14.0
- Minimum number of steps to reliably reproduce the issue
with dj.conn(**conn_info) as connection:
print(connection)
- Complete error stack as a result of evaluating the above steps
Traceback (most recent call last):
File , in <module>
app.lambda_handler(payload.EVENT, payload.CONTEXT)
File , line 136, in lambda_handler
with dj.conn(**conn_info):
AttributeError: __enter__
Expected Behavior
Using with to create a datajoint db connection, and close the connection at the end of the with clause.
AFAIK, dj.Connection does not implement a context manager. So this issue is a feature request to add context manager functionality to dj.Connection, not a bug fix.