java

Nim Sadeh 2023-12-27T02:40:51.334829Z

I am a little unfamiliar with Java, trying to chase a resource leak in a data ingest daemon I wrote in Clojure. I have a bunch of go-blocks reading files using https://docs.oracle.com/javase/8/docs/api/java/io/FileInputStream.html. They don't explicitly call close() on the stream. However, they delete the file after the stream is read into an AWS bucket. Do I need to call close explicitly on a stream after I am done with it?

2023-12-27T03:50:11.636849Z

Yes

2023-12-27T03:51:24.581349Z

Also you should not be doing blocking io like reading a file in go blocks

Nim Sadeh 2023-12-27T04:09:18.617179Z

How should I read files in clojure then?

2023-12-27T04:10:07.135109Z

Not in a go block

Nim Sadeh 2023-12-27T04:14:54.251889Z

In this case I want to have a number of processes (in the concurrency sense, not actual separate PIDs) listening on downloads coming on a conveyor belt/channel, unzip the zip files, and upload a subset of those files to AWS. How would I accomplish that outside of go blocks?

2023-12-27T04:24:55.384209Z

I guess I don't understand, are you just not familiar with threads?

2023-12-27T04:25:31.910539Z

Go blocks are not threads, they are a series of callbacks attached to channels and then executed on a fixed size threadpool

Nim Sadeh 2023-12-27T04:25:56.608499Z

Got it - I should use threads here?

2023-12-27T04:26:17.211389Z

Yes

Nim Sadeh 2023-12-27T04:26:48.615489Z

I have mostly used actor concurrency so I default to trying to replicate it where I shouldn't, thanks for the nudge.

2023-12-27T04:27:32.066929Z

There is a #core-async channel, you can search it for things like "blocking io" (not sure how useful the results are though)