[Python] How to make an asynchronous python call from within scala

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to access the Python Client V4 for DyDx from within a scala project. I integrated the previous V3 using scalapy library. But V4 contains asynchronous calls which I don't know how I should handle. So for example the short term order composite example's test function begins with the following lines:

    node = await NodeClient.connect(TESTNET.node)
    indexer = IndexerClient(TESTNET.rest_indexer)


    I can access the connect call as follows in my scala code:

    val network = py.module("dydx_v4_client.network")
    val client = py.module("dydx_v4_client.node.client")


    If I print out the value for client it gives me


    <coroutine object NodeClient.connect at 0x7fe18e87a340>
    ​

    The connect call in NodeClient is defined as asynchronous:

    async def connect(config: NodeConfig) -> Self:
    ...


    How can I actually execute this coroutine object?

    Continue reading...

Compartilhe esta Página