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

Document finalizer task-switch restriction #25141

Merged
merged 3 commits into from
Jul 5, 2019

Conversation

ihnorton
Copy link
Member

@thofma
Copy link
Contributor

thofma commented Dec 17, 2017

Could the hint about @schedule be expanded? Maybe an easy example illustrating how to print something. I think this is a very common case.

@ihnorton
Copy link
Member Author

Sure, done.

@kshyatt kshyatt added the domain:docs This change adds or pertains to documentation label Dec 18, 2017
@@ -10,6 +10,10 @@
Register a function `f(x)` to be called when there are no program-accessible references to
`x`, and return `x`. The type of `x` must be a `mutable struct`, otherwise the behavior of
this function is unpredictable.

`f` must not cause a task switch, which excludes most I/O operations such as `println`.
`@schedule println("message")` or `ccall(:jl_, Void, (Any,), "message")` may be helpful for
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like @schedule is deprecated now, so the hint should probably be to use @async

@iamed2
Copy link
Contributor

iamed2 commented Jul 17, 2018

Wow, thank you for documenting this, I had no idea

@tkf
Copy link
Member

tkf commented Oct 29, 2018

I suppose Core.println and Core.print can be used in finalizer too?

samoconnor added a commit to JuliaLang/MbedTLS.jl that referenced this pull request Nov 1, 2018
rened pushed a commit to contextflow/MbedTLS.jl that referenced this pull request Jan 10, 2019
@antoine-levitt
Copy link
Contributor

This is a pretty easy limitation to run into when debugging, and it's not obvious that IO task switching is the issue. Can this PR be merged?

@iamed2
Copy link
Contributor

iamed2 commented Jul 5, 2019

Had to ask about this on Slack, this should really be in the documentation by now

@ihnorton
Copy link
Member Author

ihnorton commented Jul 5, 2019

I can no longer update the branch, so please feel free to edit/merge as you see fit.

@StefanKarpinski StefanKarpinski merged commit 95ebe8f into master Jul 5, 2019
@StefanKarpinski StefanKarpinski deleted the ihnorton-patch-fnlz-doc branch July 5, 2019 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants