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

Add unsafe option to notify for unsafe unblocking #40475

Closed

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Apr 14, 2021

In trying to find ways to unblock readline(stdin) for implementing a timeout for Base.prompt #39027, adding an unsafe option to notify to disable concurrency violation checks, and temporarily setting the io to closed seemingly "works" without breaking the repl stdin, but I suspect it's not legal?

julia> function readline_timeout(io::Base.TTY, timeout)
           stat_before = io.status
           Timer(timeout) do t
               io.status = Base.StatusClosed
               notify(io.cond, unsafe=true)
           end
           try
               readline(io)
           finally
               io.status = stat_before
          end
       end
readline_timeout (generic function with 1 method)

julia> readline_timeout(stdin, 3)
""

julia> versioninfo()
Julia Version 1.7.0-DEV.864
Commit d02aba4c21* (2021-04-07 16:11 UTC)
...

@IanButterworth IanButterworth requested a review from vtjnash April 14, 2021 03:42
@vtjnash vtjnash closed this Apr 14, 2021
@vtjnash
Copy link
Member

vtjnash commented Apr 14, 2021

There is no point in having a lock that is unsafe to use

@IanButterworth IanButterworth deleted the ib/unsafe_notify branch April 14, 2021 05:21
@IanButterworth
Copy link
Member Author

Ok. Am I right in saying that readline being non-unblockable is a design choice? So I should quit trying to work around it?

@IanButterworth
Copy link
Member Author

Scratch that, just saw your suggestion in #39027 (comment)

I'll give that a go. Thanks

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