Repository navigation
XMLHttpRequest: non-standard unref() and ref(), like a Node.js socket - #525
Draft
wesgarland wants to merge 1 commit into
Draft
wesgarland wants to merge 1 commit into
wesgarland wants to merge 1 commit into
Conversation
A request sent after unref() runs as an asyncio task that pm.wait() does not count, so a pending request (e.g. a long-poll) does not keep the program running; ref() undoes it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds non-standard
XMLHttpRequest.prototype.unref()andref(), matching what a Node.js socket offers. A request sent afterunref()runs as an asyncio task thatpm.wait()does not count, so it does not keep the program running;ref()undoes it. Errors still reach the XHR's error handling.dcp-client needs this: under Node.js, engine.io-client's
autoUnrefoption unrefs its long-poll sockets (through xmlhttprequest-ssl), but under PythonMonkey it uses the global XMLHttpRequest, so an open dcp connection's long-poll keeps pmjs running forever.tests/js/xhr-unref.bash(a server that answers after 5 s): an unref()'d request is not waited for, a ref()'d one is. Fails on 1.5.1 (xhr.unref is not a function); passes with this change overlaid on the 1.5.1 wheel, as doestests/python/test_xhr.py.