Prevent sessions from modifying each other's posargs #439
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.
Fixes #400
Follow-up to #397
This PR gives each session its own copy of
posargs
, thereby preventing mutations in one session to affectposargs
in another session.A test is added to check that
posargs
does not bleed through between sessions. Some existing tests are updated to fix breakage due to the change. There are three groups of tests that broke:posargs
usingis
instead of==
posargs
posargs
to a mock sentinelRationale:
#397 introduced the ability to invoke
session.notify
withposargs
, allowing one session to schedule another session with its own set of positional arguments. As a consequence, every session conceptually now has its ownposargs
; these arguments are no longer necessarily those passed on the command-line. Therefore it makes sense to prevent one session from accidentally mutating theposargs
of other sessions.session.posargs
was already mutable before #397. But as all sessions received the same set of positional arguments, typical uses of positional arguments would restrict the run to a specific session. In such cases, mutating the shared copy ofposargs
would not lead to issues.While it's conceivable that users would intentionally modify posargs in one session to affect another session, this technique would rely on an undocumented implementation detail. So I don't see a backwards compatibility issue here.
Rejected Ideas:
Using a
tuple
forsession.posargs
. This would break existing use patterns which rely onsession.posargs
supporting list operations, for example in the pip project. See #400 (comment) for more details.