我使用的是运行shell_plus --notebook的Django 3.0.6和Jupyter笔记本。我尝试运行queryset:但是返回这个错误SynchronousOnlyOperation: You cannot call this from an asyncUser.objects.all())
print(user)
TypeError: 'SyncToAsync'
line 24, in inner我不完全理解为什么会发生这种情况。然后使用相同的线程调用每个任务。
这些任务不是设计为异步的,它们使用纯同步代码,这些任务执行DB查询和网络请求。django有一个用来修饰数据库操作的async_unsafe装饰符,这个装饰器检查事件循环是否正在运行,在这种情况下它会引发一个SynchronousOnlyOperation。它是OpenWISP
我试图保存使用django通道和postgresql发送的数据。created_at = models.DateField() db_table = "rawdata"
错误The exception is SynchronousOnlyOperation('You cannot call this from an async context - use a th