Closed rslinckx closed 7 years ago
Also is the try/catch on SyncScheduler really necessary ?
Your example should fix the issue :) (PR? :) )
PS: yeah, the try/catch is necessary safe/guard as, if there is any issue in the function resolution, the async instance might block any subsequent calls.
You can review pull request #31
This will attempt to dispatch key=1, will correctly queue in the event loop the batch loader, which will then receive the incorrect return value of '23' from the batch_load_fn.
It will then call failed_dispatch with the error, which will attempt to reject all pending promises, and also call loader.clear(1). The problem is:
this will throw a KeyError because the promise hasn't been cached yet, and will stall the event loop. Worse, the exception is catched by the SyncScheduler and things just stop.
A fix would be to self._promise_cache.pop(cache_key, None) for example, but i'm not sure if it has deeper implications...