Fix racey hang while unwinding wrap_py_function #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this change,
wrap_py_function
could tear down the JS callback function and stop processing callbacks, but then receive straggling callbacks that were still being transported from the V8 thread to the asyncio event loop thread. It would then the queue-accounting logic would wait on those last straggling callbacks and never finish them, since it had already torn down the processing task.Now we may still create tasks for straggling callbacks, but then we'll consistently drop those tasks if we've already stopped processing pending items.
This also gets rid of the use of
asyncio.Queue
which I realized wasn't making anything easier. (I want it to be a golang channel, but it isn't!)