Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@use_file get stuck in a loop when used in list-comprehension #13

Open
MrHenning opened this issue Jun 30, 2022 · 1 comment
Open

@use_file get stuck in a loop when used in list-comprehension #13

MrHenning opened this issue Jun 30, 2022 · 1 comment
Assignees

Comments

@MrHenning
Copy link

When I watch files using @use_file, the cell-evaluation repeats indefinitely:

image

Or in code:

# ╔═╡ d897134c-3905-49c9-bc67-cf65252fc18e
begin
	f1 = tempname()
	open(f1,"w") do io
	   println(io, "test1")
	end
end

# ╔═╡ da80d3e9-0141-4f27-b6b8-da70abc77fbc
begin
	f2 = tempname()
	open(f2,"w") do io
	   println(io, "test2")
	end
end

# ╔═╡ 71e01590-0310-40fa-97c3-3aea48c20ae4
[@use_file(f) for f in [f1,f2]]  # <-- this cell re-evaluates indefinitely

# ╔═╡ 2902b855-2289-44b0-b53b-41841be6c806
[@use_file(f1), @use_file(f2)]  # <-- this cell evaluates once

I guess that's due to a closure in the list-comprehension?

I looked into the @use_file, but didn't find any way to fix this. Maybe @use_file is just not supposed to be used like this, then one could use something @assert isfile(eval(filename)) in @use_file to "warn" users?

@Pangoraw
Copy link
Member

The issue is that Pluto Hooks are currently written with the hypothesis that each macro call is run only once per cell execution.

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

No branches or pull requests

2 participants