Skip to content

Copy select thread local state of calling thread into workers #456

Open
@dueckes

Description

@dueckes

This is a suggestion.

I was recently faced with a problem in a Rails app using Futures where log content that was run by a Future task did not contain a request uuid. It turns out that Rails stores this log related data in thread locals. To work around this, I decided to patch the ThreadPoolExecutor Worker to copy select local thread state from the invoking thread to the worker thread when it receives a message to execute.

Suggestion: through configuration / call arguments, allow workers to copy select thread state prior to performing tasks.

I believe thread synchronization models in other languages / tools support this, for instance .NET allows thread context to be shared among threads: https://msdn.microsoft.com/magazine/gg598924.aspx.

Do the ruby-concurrency team believe this idea has merit?

Metadata

Metadata

Assignees

Labels

enhancementAdding features, adding tests, improving documentation.medium-priorityShould be done soon.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions