Fork me on GitHub
#core-async
<
2016-09-09
>
val_waeselynck18:09:45

hi all, quick question for JVM experts. Assuming I start a core.async process which loops forever, should I register a JVM shutDownHook to stop it ?

tanzoniteblack18:09:42

@val_waeselynck in most situations like that, I prefer to just start a java thread in daemon mode, so I don’t have to worry about the internal details of how the core.async processes are being run (which is not guaranteed not to change in future versions)

val_waeselynck18:09:57

@tanzoniteblack not sure I understand, what thread should be started in daemon mode? I'm using go blocks, which spin off logical threads not real ones, so not sure I have control over that

tanzoniteblack18:09:32

I guess it depends on what you mean by “loops forever”; if you have something like “sleep for 5 minutes then run some house keeping job, and I don’t want this to stop the program from shutting down”, then I’m recommending not using a go block (or anything related to core.async), and instead just use a regular old java thread put into daemon mode

val_waeselynck18:09:24

@tanzoniteblack sadly no, it's more like "poll this high-throuput SQS endpoint"

tanzoniteblack18:09:57

and what’s the termination condition on the program? I.e. does it quit when some other function has finished running, or does it only ever get killed when you manually kill it?

val_waeselynck18:09:23

manually, it's a web server basically

val_waeselynck18:09:29

or say a worker polling on a queue

tanzoniteblack18:09:57

then no, you don’t need to register a JVM shutDownHook; when you manually kill the JVM to kill the server, the JVM will clean up threads it created, like the threads running go-blocks

tanzoniteblack18:09:31

(the JVM won’t necessarily clean up other processes, but you’re almost certainly not creating any of those with go blocks and SQS polls)

Alex Miller (Clojure team)20:09:05

I released a new core.async version today - 0.2.389, no major changes mostly just to get a fix for the bounded-count warning with Clojure 1.9 out there