Code Monkey home page Code Monkey logo

Comments (6)

dblock avatar dblock commented on May 28, 2024 1

I think this is because the buffer for the web socket is flushed later. I see two options:

EM.next_tick do
 client.say ...
end

Or EM.defer for a long running thing.

Or use a web client, client.web_client.chat_postMessage(channel: ..., text: ...) which will use the web API to post immmediately.

Generally I think you don't want to block, so I think wrapping the long operation in EM.defer is probably the best solution.

Le us know which one works best?

from slack-ruby-bot.

gcraig99 avatar gcraig99 commented on May 28, 2024 1

I've also noticed that while doing said long running operation that the bot doesn't respond to other requests. So I've taken to running the blocks for any commands that take a while in a new thread. This allows the bot to answer other questions at the same time. One thing to note, that will break test cases as the test case doesn't know to wait for the detached thread. To solve this I enclose the block in a lambda and then check if the environment is test, if so execute the block without the thread, otherwise pass the block to the thread to be run.

from slack-ruby-bot.

gcraig99 avatar gcraig99 commented on May 28, 2024

I noticed this is the behavior with faye-websocket but if you use celluloid-io gem then you get one message, then the pause while it works, then the next response.

from slack-ruby-bot.

kstole avatar kstole commented on May 28, 2024

I found that using Celluloid.defer seems to work for allowing the bot to respond to other commands while processing a long-running command. It also allows me to use client.say in the deferred block. Maybe this (or something similar) should become a standard feature in how SlackRubyBot responds to commands?

from slack-ruby-bot.

dblock avatar dblock commented on May 28, 2024

I am down with a global option to defer execution of all commands, including regex parsing. Would love a PR, please!

from slack-ruby-bot.

kstole avatar kstole commented on May 28, 2024

I suppose it would then need to be something that works w/ both Celluloid and EventMachine. Possibly not too much code to implement but would certainly require major changes to the specs.

from slack-ruby-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.