Future termination

270 views
Skip to first unread message

Serzh Nechyporchuk

unread,
Jul 30, 2014, 3:33:37 PM7/30/14
to clo...@googlegroups.com
Hello. I have a problems using code with futures. For example, if I run following code:

java -jar clojure-1.6.0.jar -e "(println 1)"

the process prints 1 and terminates.
But when I'm trying to run code with futures:

java -jar clojure-1.6.0.jar -e "(future 1)"

the process doesn't terminates.

This has real implication when I run some task using 

lein run -m some-ns/fun args

If code above uses futures then this process will not terminate. This is really frustrating.

Andy Fingerhut

unread,
Jul 30, 2014, 3:50:11 PM7/30/14
to clo...@googlegroups.com
Never is an awfully long time :-)  If you wait about 60 seconds, the command you gave calling (future 1) does terminate, at least on Mac OS X 10.8.5 where I tested it, and I have seen the same behavior on Linux and I think Windows.

This version terminates much more quickly:

java -jar clojure-1.6.0.jar -e "(future 1) (shutdown-agents)"

There is some discussion of this issue at the ClojureDocs page for the function 'future', including that this issue affects pmap and clojure.java.shell/sh, too, because are both implemented using futures:

    http://clojuredocs.org/clojure_core/clojure.core/future

It also includes a link to a Clojure ticket suggesting that this behavior change.  You can vote on it if you like (requires a Clojure JIRA account, which you can create by clicking on the "Log In" link near the top right of the page):

    http://dev.clojure.org/jira/browse/CLJ-124

Andy



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Serzh Nechyporchuk

unread,
Jul 31, 2014, 8:38:04 AM7/31/14
to clo...@googlegroups.com
On my Ubuntu 14.04 laptop process doesn't terminates at all. I was waiting about an hour.
Also this issue affects code which uses datomic.api, which, I think, uses futures too.

Середа, 30 липня 2014 р. 22:50:11 UTC+3 користувач Andy Fingerhut написав:

Andy Fingerhut

unread,
Jul 31, 2014, 10:21:50 AM7/31/14
to clo...@googlegroups.com
Serzh:

Could you give a few details about the software machine where you saw it not terminate, even after an hour?  I may try collecting some info like this to add to the Clojure ticket.  In particular, the outputs of the following commands.

java -version
uname -a
lsb_release -d
time java -jar clojure-1.6.0.jar -e "(future 1) (shutdown-agents)"
time java -jar clojure-1.6.0.jar -e "(future 1)"

For that last one, if it runs more than 2 minutes without terminating, you can kill it.  No need to wait for an hour.

I have tried Ubuntu 14.04 desktop 64-bit running in a VM on my Mac, and the last command above terminates in about 60 seconds, for several different JVM versions (mostly Oracle).  Yours is the first case I've heard of not terminating after about a minute, so wanted to try to reproduce that case.

I think it would be good if it took the same short time to terminate as if you call shutdown-agents, even without calling shutdown-agents.  I may also work on a patch for that ticket, after trying to summarize the long list of comments.

Thanks,
Andy

Serzh Nechyporchuk

unread,
Aug 20, 2014, 4:24:06 AM8/20/14
to clo...@googlegroups.com
Sorry for my delayed answer. I've tried examples with only futures that you give and they works really fine, all agent were closed.
 And I figured out that this problem arises only when I using datomic.api.

> java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:        14.04
Codename:       trusty

> uname -a
Linux serzh-System-Product-Name 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


> time java -cp `lein classpath` clojure.main  -e "(require 'datomic.api) (shutdown-agents)" 
java -cp `lein classpath` clojure.main -e   3,03s user 0,12s system 109% cpu 2,870 total


> time java -cp `lein classpath` clojure.main  -e "(require 'datomic.api)" 
# This doesn't released.

Четвер, 31 липня 2014 р. 17:21:50 UTC+3 користувач Andy Fingerhut написав:

-- 
Best regards,
Serhii Nechyporchuk

Четвер, 31 липня 2014 р. 17:21:50 UTC+3 користувач Andy Fingerhut написав:
Reply all
Reply to author
Forward
0 new messages