Ananto30/zero

Zero server returned result was not right when client started in multi threads

Closed this issue · 2 comments

This is my test script:
server:

import time

from zero import ZeroServer


def echo(msg: str) -> str:
    # mock do something
    time.sleep(5)
    return msg


if __name__ == "__main__":
    app = ZeroServer(port=5559)
    app.register_rpc(echo)
    app.run()

client:

from zero import ZeroClient
from threading import Thread


def test(index):
    zero_client = ZeroClient("localhost", 5559, 20000)
    data = zero_client.call("echo", f"{index}")
    print(data)


if __name__ == "__main__":
    for i in range(16):
        Thread(target=test, args=(i,)).start()

This is working for me perfectly. Can you please mention what are you observing wrong?

If you print with index you will find it's printing the same as echo.

print(index, data)

Like this is my test result -
image

Yes,It's my console problem.Sorry for that.