Python 与django进行异步事务

Python 与django进行异步事务,python,python-3.x,django,async-await,webhooks,Python,Python 3.x,Django,Async Await,Webhooks,我有一个如下的代码结构。当我运行应用程序时,我得到如下错误。我怎样才能解决这个问题? 数据库postgresql raise SynchronousOnlyOperation(message) django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async. 这方面有更新吗? raise Sy

我有一个如下的代码结构。当我运行应用程序时,我得到如下错误。我怎样才能解决这个问题? 数据库postgresql

     raise SynchronousOnlyOperation(message)
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

这方面有更新吗?
     raise SynchronousOnlyOperation(message)
     django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.
@require_POST
@csrf_exempt
def webhook(request):
    webhook_received_json = json.loads(request.body)

    queryset = CryptoInfo.objects.filter(symbol=webhook_received_json['symbol'])
    table_data = serializers.serialize('json', queryset)

    for pair_list in json.loads(table_data):
        if pair_list['fields']['symbol'] == webhook_received_json['symbol']:

            # position update entryPrice
            asyncio.run(get_position_update(futures_api_key=pair_list['fields']['futures_api_key'],
                                            futures_secret_key=pair_list['fields']['futures_secret_key'],
                                            symbol=pair_list['fields']['symbol'],))




async def get_position_update(futures_api_key, futures_secret_key, symbol):
    client = Client(futures_api_key, futures_secret_key)

    data = client.futures_position_information()
    for sym in data:
        if sym['symbol'] == symbol and sym['positionAmt']:
            await CryptoInfo.objects.filter(futures_api_key=futures_api_key,
                                      futures_secret_key=futures_secret_key,
                                      symbol=sym['symbol']).update(
                entryPrice=sym['entryPrice'])
    return get_position_update