core-async

2020-03-05T07:10:26.209Z

@kwladyka I think since core.async can easily lock up its threads, it distracted us from the fact that it could be your job that do instead

2020-03-05T07:10:42.209400Z

I'd say, you probably want to add some form of timeout to your jobs then

2020-03-05T07:34:33.212100Z

(alt!
  (timeout 10000)
  :timed-out
  (thread
    (try
      (job)
      :success
      (catch Throwable ex
        :error)))
  ([result] result))))

2020-03-05T07:34:52.212300Z

And log something on timeout

2020-03-05T07:35:46.213Z

Could be useful in the future, if any other job happens to go on forever, then you'll know

2020-03-05T07:36:35.213900Z

Question to others: Would there be a way to get the thread created by core.async thread? So that we could interup it?

mccraigmccraig 2020-03-05T08:57:18.214200Z

pass a channel in to your core.async thread, put the java.lang.Thread/currentThread on to it ?

mpenet 2020-03-05T09:24:30.214400Z

you should have a way to allow a clean exit of that Thread

mpenet 2020-03-05T09:24:32.214600Z

instead

mpenet 2020-03-05T09:25:42.214800Z

listening on an poison-pill kind of chan for this from inside your async/thread is a way to do this. could be a simple promise-chan that you close! to signal exit and then listen to via alts inside the thread

mccraigmccraig 2020-03-05T09:59:56.215Z

but if your thread is blocking on some i/o, or other monitor, you may need to interrupt it, if it's not going to timeout and clean itself up ?

2020-03-05T10:50:02.217200Z

one thing to think about when exposing the thread is that once the job is done, the thread can be assigned to another job.

2020-03-05T10:50:27.217400Z

you may interrupt that other job accidentally

mccraigmccraig 2020-03-05T11:00:20.217600Z

oh, yeah, so if you are going to interrupt you really need to be sure that you are interrupting the thing you intend to interrupt, and not the next thing that thread is being re-used for

2020-03-05T11:01:08.217800Z

yes

2020-03-05T11:01:25.218Z

not impossible, but surprisingly hard to get right

mccraigmccraig 2020-03-05T11:05:13.218200Z

could be nicely wrapped in, say, an interruptable-thread fn which returns [result-chan safe-interrupt-fn]

2020-03-05T11:06:33.218400Z

that looks like a future

mccraigmccraig 2020-03-05T11:13:03.218600Z

it does rather - which makes sense

alexmiller 2020-03-05T13:05:37.222200Z

If you’re wanting to interrupt stuff then it sounds like a blocking op, which you should not do in a go loop, so you can set those aside. Others threads that do channel work are not special to core.async, they’re just normal threads. If you want to create one and interrupt it, go for it.

alexmiller 2020-03-05T13:06:47.223900Z

I’m assuming you mean like http://Thread.interrupt(). If you mean something less formal, then channels are the best way to communicate information to processes

2020-03-06T03:58:32.230700Z

Hum... Does async/thread works off a thread pool?

2020-03-06T03:59:21.230900Z

My initial thought was to wrap the work in async/thread in a future as well and interup that, but I felt dumb double spawning a thread just for that

alexmiller 2020-03-06T04:11:44.231100Z

async/thread does, but async/thread is not special - you can just make your own Thread and do channel stuff on it too

2020-03-06T04:15:37.231300Z

Ya, that can work. Needs a bit more scaffolding but makes sense.

kwladyka 2020-03-05T10:33:36.216300Z

@didibus I don’t think this is the right solution, because thread which stuck will consume memory forever. After a while this can make OOM. Unless I am wrong and the thread will be killed?

2020-03-06T21:11:58.243Z

You're right, that's why I asked about interup.

kwladyka 2020-03-05T10:33:48.216600Z

I would prefer timeout on thread instead

kwladyka 2020-03-05T10:36:30.217100Z

But not sure how this should be done. I didn’t have time to go deeper into it.

orestis 2020-03-05T14:22:11.224400Z

I’m seeing this error in TravisCI: Could not find artifact org.clojure:core.async:jar:1.0.567 in central (<https://maven-central.storage-download.googleapis.com/repos/central/data/>)

orestis 2020-03-05T14:23:54.225200Z

Not sure what’s going on there, probably related to the recent version bumps?

alexmiller 2020-03-05T14:29:31.225800Z

if that's a mirror, could be lagging central (although that's quite a lag)

alexmiller 2020-03-05T14:29:38.226100Z

central: https://repo1.maven.org/maven2/org/clojure/core.async/1.0.567/

alexmiller 2020-03-05T14:30:19.226600Z

I would expect to find core.async jar in that mirror at https://maven-central.storage-download.googleapis.com/repos/central/data/org/clojure/core.async/1.0.567/core.async-1.0.567.jar

alexmiller 2020-03-05T14:30:25.226800Z

but it isn't there

orestis 2020-03-05T14:31:34.227Z

Yeah that’s odd

orestis 2020-03-05T14:31:55.227300Z

I will raise an issue with Travis

alexmiller 2020-03-05T14:32:25.227700Z

it doesn't have the version before that either (0.7.559)

alexmiller 2020-03-05T14:32:43.228100Z

it does have 0.6.532 which dates back to December

orestis 2020-03-05T14:42:43.228700Z

Not sure why Travis is using that mirror — that’s certainly not a mirror I’ve defined in my deps.edn

orestis 2020-03-05T14:45:39.229Z

https://travis-ci.community/t/disable-google-maven-central/5301 — probably a question for tools.deps?

alexmiller 2020-03-05T14:51:23.229400Z

tools.deps is not doing anything to use that

alexmiller 2020-03-05T14:51:53.230Z

tools.deps does support mirrors in settings.xml so if you set that up, it should take effect

orestis 2020-03-05T14:52:46.230600Z

Hm, I need to learn about maven now 😄 — killing the cache as the thread suggested seems to have fixed things.