tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

when i use @atomic, it has "TypeError: wrapper() got an unexpected keyword argument 'data_list'"

Open night-zhang opened this issue 5 years ago • 2 comments

Describe the bug Hi, In my project,I encapsulate a function 'insert_many'.When i use the @atomic, it has a typeerror: "TypeError: wrapper() got an unexpected keyword argument 'data_list'"

    @classmethod
    @atomic
    async def insert_many(cls, data_list=None):
        if not all([data_list, isinstance(data_list, (list, tuple))]):
            return 'INVALID_PARAM', {}
        data_len = len(data_list)
        for i in range(0, data_len, constant.DB_STEP):
            await cls.bulk_create([cls(**item) for item in data_list[i:(i + constant.DB_STEP)]])
        return 'SUCCESS', data_len

Did I use the wrong way about @atomic?

Additional context My project use the tornado framework and the traceback is as follows.

Traceback (most recent call last):
  File "\project\xxx\handler\_base.py", line 160, in item_handler
    return await method()
  File "\project\xxx\handler\some\some.py", line 29, in create_many
    status, res = await self.some_service.create_many(data_list=data_list)
  File "\project\xxx\service\some\some.py", line 39, in create_many
    res = await self.dm.some_object.insert_many(data_list=data_list)
TypeError: wrapper() got an unexpected keyword argument 'data_list'

night-zhang avatar Jan 26 '21 06:01 night-zhang

use @atomic()

long2ice avatar Jan 26 '21 06:01 long2ice

use @atomic()

Oh,it's a basic grammar,my mistake.Thank you very much.

night-zhang avatar Jan 26 '21 10:01 night-zhang