Hey, first of all thanks for sharing!
I'm trying to populate my database using a Data Migration.
In my populate function I have 2 api calls, so the shape is something like this:
async def populate_table(apps, schema_editor): some stuff... an api call like: await get_info()... an api call inside a for loop (any problem with this?) for i in range(): an api call like: await get_another_info()... more stuff... model.save()
And then, I have my migration class:
class Migration(migrations.Migration): dependencies = [ ('app', 'the previous migration'), ] operations = [ migrations.RunPython(populate_table) ]
Running the migration a Runtime Warning is raised:
RuntimeWarning: coroutine 'populate_table' was never awaited
So I try to decorate my Migration with Async Await without success.
How should I do that? And again, any problem to have async tasks inside a sync for loop?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey, first of all thanks for sharing!
I'm trying to populate my database using a Data Migration.
In my populate function I have 2 api calls, so the shape is something like this:
And then, I have my migration class:
Running the migration a Runtime Warning is raised:
So I try to decorate my Migration with Async Await without success.
How should I do that? And again, any problem to have async tasks inside a sync for loop?