Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python context manager raises error with datajoint connection object #1081

Open
yambottle opened this issue Mar 16, 2023 · 1 comment
Open
Assignees
Labels

Comments

@yambottle
Copy link
Contributor

yambottle commented Mar 16, 2023

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.

@yambottle yambottle added the bug label Mar 16, 2023
@yambottle yambottle changed the title Creating connection object with python context manager Python context manager raises error to close the connection object Mar 14, 2024
@yambottle yambottle changed the title Python context manager raises error to close the connection object Python context manager raises error with datajoint connection object Mar 14, 2024
@ethho ethho self-assigned this Sep 13, 2024
@ethho
Copy link
Contributor

ethho commented Sep 13, 2024

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.

@ethho ethho added features and removed bug labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants