Skip to content

sklearn.callbacks._transport.open_listener should document thread-safety requirements #34145

Closed

Description

@itamarst

Describe the issue linked to the documentation

The message_consumer callable argument to sklearn.callbacks._transport.open_listener() can be called from multiple threads within the same process, when using a thread pool instead of a process pool. That means it needs to be thread-safe.

In practice all callers are actually thread-safe, so that's not a problem.

However, this requirement is not documented.

Suggest a potential alternative/fix

Add a note saying that the message_consumer might be called from multiple different threads and must be prepared to handle this correctly.

I'm happy to do this.

Activity

  1. removed
    Needs Triage
    on May 28, 2026
  2. jeremiedbb commented on May 28, 2026

    @jeremiedbb
    Member

    That's correct, the message_consumer is expected to be thread safe. A improvement of the docstring of open_listener is welcome.

  3. Git169-hub commented on Jun 1, 2026

    @Git169-hub

    Hi, I looked into this issue and cloned the current main branch to check. The thread-safety requirement for message_consumer is already documented in the current docstring for open_listener in sklearn/callback/_transport.py:
    "This callable may be called from multiple different threads, and must therefore behave in a thread-safe manner."
    It looks like this was already addressed. Could a maintainer confirm if this issue can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions