I followed with this guide to write a session_scope for SQLAlchemy. When I run the code, I am getting an AttributeError exception:
Traceback (most recent call last):
  File "/Users/tuanchauict/workspace/opla-manga/python-server-non-django/demo.py", line 56, in <module>
    with session_scope() as s:
AttributeError: __exit__
My code is:
Session = sessionmaker(bind=engine, autocommit=False, autoflush=False)
def session_scope():
    session = Session()
    try:
        yield session
        session.commit()
    except Exception as e:
        session.rollback()
    finally:
        session.close()
with session_scope() as session:  # <=== error here
    pass
I am running Python 3.4 on Mac OS 10.10.