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

Derefing a future hangs #29

Open
vemv opened this issue Nov 17, 2017 · 4 comments
Open

Derefing a future hangs #29

vemv opened this issue Nov 17, 2017 · 4 comments

Comments

@vemv
Copy link

vemv commented Nov 17, 2017

I have a fix.clj with the following contents:

(require '[dev.formatting.fix])

@(dev.formatting.fix/fix!)

Where @ is used to wait on a future.

lein exec -p scripts/formatting/fix.clj hangs forever. If I run the same exact code in lein repl, it won't.

What could it be going on here?

Cheers - Victor

@vemv
Copy link
Author

vemv commented Nov 17, 2017

Workaround: adding (System/exit 0) at the end of the script

@kumarshantanu
Copy link
Owner

@vemv Could you try adding (shutdown-agents) instead? It's likely that the script is blocked because the thread pool is still active with non-daemon threads.

@vemv
Copy link
Author

vemv commented Nov 23, 2017

Tried out!

Unfortunately it didn't work:

(println :a)
(shutdown-agents)
(println :b)

This prints :a, :b then hangs forever.

This doesn't happen in a project created from scratch. But in a real production project there are too many dependencies to determine the culprit.

Perhaps the simplest thing would be to recommend (System/exit 0) in the README.

Cheers - Victor

@kumarshantanu
Copy link
Owner

I'm not sure what the problem could be - does the code you call launch a thread-pool that you are not shutting down in your script? When I execute future in a simple script I am unable to reproduce the problem. Do you have a minimal standalone script that can reproduce the issue?

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