Skip to content

How to catch exceptions inside a ThreadPool #616

Closed
@kalsan

Description

@kalsan

We are using FixedThreadPools in a large Rails application. Due to the size of the project, we have a large variety of control flows including returns and all kinds of exceptions.

In order to deal with exceptions inside a FixedThreadPool, we are forced to use a workaround with a block with_exception_catching do...end, but it's a terribly ugly hack that is becoming harder and harder to maintain as our application grows in complexity.

Despite long hours of research, we haven't found a cleaner solution in the Internet. Interestingly, not long ago someone else has come up with a similar workaround here: http://stackoverflow.com/questions/40718759/handle-exceptions-in-concurrent-ruby-thread-pool (Reply by grossadamm).

Not being able to deal with exceptions inside threads is a problem that affects so many people. I can't believe there isn't already a solution implemented in FixedThreadPool. So I've got to come up with this question: Isn't there a cleaner way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAn user question, does not change the library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions