Ananto30/zero

Mixed results

Closed this issue · 3 comments

Getting mixed results from server
since client is non blocking if you call method1 say "method1" twice you get the fastest response as result for first call
#call1
router.call("method1",msg) # first call taks 1sec
#call2
router.call("method1",msg) # second call taks less (0.5sec)

the part waiting for results with async will queue (call1,call2) but response from wrokers will be (call2, call1)
the server will return result2 for call1 and result1 for call2

to reproduce set one method that takes dynamic time to finish call it multiple times the results will be ordered by time of execution not order of calling. no suitable for concurrent tasks (maybe your tests included only sequencial calls of different methods)

in client

async def route(command,__retry=0,**args):
    router = await _get_router()
    msg= {"command":command,**args}
    result = await router.call("process",msg)
    if result:
        if "error" in result:
            raise EnsureBaseError(result['error'])
        elif "result" in result:
            return result['result']
    else :
        # None response, call failed
        if __retry<3:
            logging.info(f"Retry {__retry}")
            return await route(command=command,__retry=__retry+1,**args)
    return result

server
app = ZeroServer(port=5559,encoder=encode ,decoder=decode)
app.register_rpc(process)
app.run(workers)

Interesting. This should not happen. The mapping is done by the router itself. Can you provide the exact script where you are facing this? @kimboox44

As @kimboox44 is not responsive, closing this.

I could reproduce the issue and solved here #29