This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script demonstrates the use of nested transactions in SQLAlchemy, including | |
a workaround for an issue with the SQLite backend. | |
References: | |
http://docs.sqlalchemy.org/en/latest/orm/session_transaction.html#using-savepoint | |
http://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl | |
""" | |
from sqlalchemy import Column, String, Integer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import asyncio | |
async def run_coro_threadsafe(self, coro, other_loop, our_loop = None): | |
"""Schedules coro in other_loop, awaits until coro has run and returns | |
its result. | |
""" | |
loop = our_loop or asyncio.get_event_loop() | |
# schedule coro safely in other_loop, get a concurrent.future back |