Hello guys!

I'm stucked on this problem, i have some script to save data to database 
using a django object.

The script is with async,so i have to use the 'sync_to_async' function.

Beyond that, running the script raise the ASynchronous exception, but it's 
look correct.

Code:

```
    async def cycle_send_to_dj(self, *args):
        """
        Leer la cola que recibe de rmq
        Enviar cada dato recibido de la cola y cargarlo
        """
        queue = args[0]
        data = []
        try:
            #breakpoint()
            async for elem in read_async_queue(queue):
                gprint("Recibiendo data en async queue")
                rprint(elem)
                # transformar elem para que sea guardable
                try:
                    data_log = await statusdata2log(
                        elem.get("station"), **elem.get("data"))
                    if data_log:
                        try:
                            bprint("="*20+">")
                            gprint("Data log::::")
                            rprint(data_log)
                            bprint("ready to build")
                            breakpoint()
                            value = await 
sync_to_async(LogUnidadGNSS)(**data_log)
                            rprint(value)
                            data.append(value)
                        except Exception as e:
                            bprint("Creando lista de logs, error %s, 
LogUnidadGNSS create" % e)
                            raise e
                except Exception as e:
                    print("Error al transformar elem %s" % e)

            gprint("Data to save")
            [print(elem) for elem in data]
            if data:
                #await  dbaccess(LogUnidadGNSS.objects.bulk_create)(data)
                await dbaccess(LogUnidadGNSS.objects.bulk_create)(data)
        except Exception as e:
            print("Hubo una excepción al guardar los datos de LogGNSS")
            raise e
        return args
```

I'm worng in somethinkg?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70ef401a-636d-4464-a912-a3f004e2de3a%40googlegroups.com.

Reply via email to