1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Approach to manage bidirectional asynchronous communication in Python

Discussão em 'Python' iniciado por Stack, Outubro 4, 2024 às 02:52.

  1. Stack

    Stack Membro Participativo

    I have two computers: PC1 and PC2 connected to the same network. Each computer will execute the following programs, respectively:

    # PC1

    while True:
    # Send data to PC2
    # Run a script that takes 1 sec
    # Receive data from PC2 (can be skipped if PC1 is not ready)


    # PC2

    while True:
    # Receive data from PC1
    # Run a script that takes 10 sec
    # Send data to PC1


    There is an imbalance, where PC1 sends and receives data more frequently than PC2. How can this case be handled? I suppose there has to be a buffer to temporarily store the data sent by PC1.

    According to what I read, asyncio might be the way to go, but I am still somewhat unsure of what the code looks like, and if that's a good option given my situation. Moreover, if simply using socket is enough, that would be great.

    I'd appreciate any suggestion. Happy to provide more context if you think it is useful.

    Continue reading...

Compartilhe esta Página