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

@sync with a timeout? #3793

Closed
amitmurthy opened this issue Jul 23, 2013 · 1 comment
Closed

@sync with a timeout? #3793

amitmurthy opened this issue Jul 23, 2013 · 1 comment
Labels
multithreading Base.Threads and related functionality parallelism Parallel or distributed computation

Comments

@amitmurthy
Copy link
Contributor

I was wondering if it would be possible to have a @sync block with a timeout like the below code does using a condition variable.

tic()
c = Condition()
cbfunc(aw, status) = begin
        println("Timer triggered!")
        notify(c, :ok)
        stop_timer(aw)
end
t = TimeoutAsyncWork(cbfunc)
start_timer(t, 2.0, 0)

@async begin
    @sync begin
        @async begin
            sleep (5.0)
        end
    end
    notify(c, :ok)
    stop_timer(t)
    println("@async triggered!")
end
wait(c)
toc()

The above code works fine, it avoids polling too - I just thought it will be more useful if it can be provided by @sync itself and I couldn't think of an obvious way to do it.

Feel free to close this issue if it cannot be done, or extending @sync with a timeout is not recommended.

cc: @loladiro , @vtjnash , @JeffBezanson

@kshyatt kshyatt added parallelism Parallel or distributed computation multithreading Base.Threads and related functionality labels Aug 2, 2016
@ViralBShah
Copy link
Member

I believe the general view has been that we do not want timeouts in this API. Can reopen if necessary.

IanButterworth pushed a commit that referenced this issue Feb 19, 2024
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 6dd0e7c9e
New commit: 76070d295
Julia version: 1.12.0-DEV
Pkg version: 1.11.0(Does not match)
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@6dd0e7c...76070d2

```
$ git log --oneline 6dd0e7c9e..76070d295
76070d295 Prevent repl crash on invalid command (#3800)
d267986c2 RFC: stop testing non-ARM on mac on CI (#3794)
2571be6d1 CI: Add Apple Silicon (macOS aarch64) to the CI matrix (#3793)
3075fb78c Simplify Pkg.Registry APIs. (#3785)
e6f1e0902 Explain about Manifest.toml per julia version (#3791)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
KristofferC pushed a commit that referenced this issue Feb 26, 2024
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 6dd0e7c9e
New commit: 76070d295
Julia version: 1.12.0-DEV
Pkg version: 1.11.0(Does not match)
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@6dd0e7c...76070d2

```
$ git log --oneline 6dd0e7c9e..76070d295
76070d295 Prevent repl crash on invalid command (#3800)
d267986c2 RFC: stop testing non-ARM on mac on CI (#3794)
2571be6d1 CI: Add Apple Silicon (macOS aarch64) to the CI matrix (#3793)
3075fb78c Simplify Pkg.Registry APIs. (#3785)
e6f1e0902 Explain about Manifest.toml per julia version (#3791)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
(cherry picked from commit 59102aa)
tecosaur pushed a commit to tecosaur/julia that referenced this issue Mar 4, 2024
…#53357)

Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 6dd0e7c9e
New commit: 76070d295
Julia version: 1.12.0-DEV
Pkg version: 1.11.0(Does not match)
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@6dd0e7c...76070d2

```
$ git log --oneline 6dd0e7c9e..76070d295
76070d295 Prevent repl crash on invalid command (JuliaLang#3800)
d267986c2 RFC: stop testing non-ARM on mac on CI (JuliaLang#3794)
2571be6d1 CI: Add Apple Silicon (macOS aarch64) to the CI matrix (JuliaLang#3793)
3075fb78c Simplify Pkg.Registry APIs. (JuliaLang#3785)
e6f1e0902 Explain about Manifest.toml per julia version (JuliaLang#3791)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality parallelism Parallel or distributed computation
Projects
None yet
Development

No branches or pull requests

3 participants