Does Clojure Ring create a thread for each request?

Viewed 1251

I am making a Messenger bot and I am using Ring as my http framework.

Sometime I want to apply delays between messages sent by the bot. My expectation would be that it is safe to use Thread/sleep because this will make the active thread sleep and not the entire server. Is that so, or should I resort to clojure/core.async?

This is the code I would be writing without async:

  (match [reply]

    ; The bot wants to send a message (text, images, videos etc.) after n milliseconds
    [{:message message :delay delay}] 
    (do
      (Thread/sleep interval delay)
      (facebook/send-message sender-id message))
    ; More code would follow...

A link to Ring code where its behaviour in this sense is clear would be appreciated, as well as any other with explanation on the matter.

2 Answers
Related