Skip to content

Use ScopedValue to fix async issue#112

Merged
omus merged 10 commits intomasterfrom
ox/scoped_variables
Jul 13, 2024
Merged

Use ScopedValue to fix async issue#112
omus merged 10 commits intomasterfrom
ox/scoped_variables

Conversation

@oxinabox
Copy link
Copy Markdown
Member

In julia 1.11 we get a proper way to do what ContextVariablesX did with an hack.

This is a rebasing of #91 with that switch over
it should not run into the issues that required #93

julia> f() = "original"
f (generic function with 1 method)

julia> p = @patch f() = "mocked"
Patch{typeof(f)}(f, var"##f_patch#233")

julia> apply(p) do
       @show Mocking.PATCH_ENV[]
       end;
Mocking.PATCH_ENV[] = Mocking.PatchEnv(Dict{Any, Vector{Function}}(f => [var"##f_patch#233"]), false)

@oxinabox oxinabox requested a review from omus February 26, 2024 11:38
Copy link
Copy Markdown
Member

@omus omus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Needs a bit of work but I'm glad we're seeing real support for this.

activate()
end

@deprecate set_active_env(f, pe) with_active_env(f, pe) false No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a proper deprecation as set_active_env would have it's changes persist beyond the scope of f. I think we should probably just make this a breaking change

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair, though this is what the previous change did, modulo also renaming set_active_env.
That function isn't actually exported.
Since the normal way to do it is to use apply(pe) do.
More an internal implementation detail of apply ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm okay with stating that set_active_env and get_active_env are internal functions and don't require deprecations. Making this a breaking change would be the safest but I could be convinced to have this be non-breaking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it breaks something can always revert, tag patch, and rerelease as breaking

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will just delete them both and not deprecate

Copy link
Copy Markdown
Member

@omus omus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a version bump. I'm happy to pick up this PR if you want.

activate()
end

@deprecate set_active_env(f, pe) with_active_env(f, pe) false No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm okay with stating that set_active_env and get_active_env are internal functions and don't require deprecations. Making this a breaking change would be the safest but I could be convinced to have this be non-breaking.

@omus
Copy link
Copy Markdown
Member

omus commented Mar 12, 2024

Going to kick start the CI workflow

@omus omus closed this Mar 12, 2024
@omus omus reopened this Mar 12, 2024
@omus omus changed the title uses ScopedValues to fix async issue Use ScopedValue to fix async issue Jul 13, 2024
@omus omus merged commit 0a12d05 into master Jul 13, 2024
@omus omus deleted the ox/scoped_variables branch July 13, 2024 06:33
@omus
Copy link
Copy Markdown
Member

omus commented Jul 16, 2024

The change here broke the test case on Julia 1.11+ which was testing for issue #108. I'll roll this change back temporarily and include it in a breaking release.

omus added a commit that referenced this pull request Jul 16, 2024
omus added a commit that referenced this pull request Jul 16, 2024
omus added a commit that referenced this pull request Jul 16, 2024
* Use ContextVariablesX to fix async issue

* Use ScopedValues rather than ContextVariables

* Apply suggestions from code review

Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>

* Define missing PATCH_ENV

* Refactor tasks testset into async scope

* Import ScopedValue alongside other imports

* Use VERSION check instead

---------

Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>
omus added a commit that referenced this pull request Jul 23, 2024
* Use `ScopedValue` to fix async issue (#112)

* Use ContextVariablesX to fix async issue

* Use ScopedValues rather than ContextVariables

* Define missing PATCH_ENV

* Refactor tasks testset into async scope

* Import ScopedValue alongside other imports

* Use VERSION check instead

---------

Co-authored-by: Curtis Vogt <curtis.vogt@gmail.com>

* Test against Julia 1.11

* Update async-world-ages tests

---------

Co-authored-by: Frames White <oxinabox@ucc.asn.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants