We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Peewee related task context such as connection or transaction_depth is stored in TaskLocals object with id(asyncio.current_task()) acts like a key.
This behavior causes painful problem with asyncio.gather inside transaction block:
from models import TestModel class MyTest(BaseTest): async def create_obj(self): return await self.objects.create(TestModel) async def get_obj(self, obj_id): await self.objects.get(TestModel, TestModel.id == obj_id) async def indirect_get_obj(self, obj_id): await self.get_obj(obj_id) async def ensured_get_obj(self, obj_id): await asyncio.ensure_future(self.get_obj(obj_id)) async def test_transaction(self): async with self.objects.atomic(): obj_id = (await self.create_obj()).id await self.objects.get(TestModel, TestModel.id == obj_id) await self.get_obj(obj_id) await self.indirect_get_obj(obj_id) with self.assertRaises(TestModel.DoesNotExist): # new tasks loose context and spawn new db connections await self.ensured_get_obj(obj_id) await asyncio.gather(self.get_obj(obj_id))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Peewee related task context such as connection or transaction_depth is stored in TaskLocals object with id(asyncio.current_task()) acts like a key.
This behavior causes painful problem with asyncio.gather inside transaction block:
The text was updated successfully, but these errors were encountered: