Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Write to Kafka from Dask Stream

Abierto
#315 0 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
kafka, python

Línea de trabajo

Start by reviewing the existing DaskStream and core.to_kafka implementations, including to_kafka.update and the get_producer workaround shown in the issue. Determine how the existing back-pressure handling and worker-local Kafka connection should fit together without pickling the producer. Done means Dask Stream can write to Kafka with the existing back-pressure behavior and a reliable worker-side producer.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

It seems like the exiting PR for this needs improvements. I'm creating this issue to invite discussion on now to properly solve this problem.

I would like to use the existing back pressure handling implementation in the existing to_kafka function. I'm thinking that we can just call the existing to_kafka.update from Dask. It looks something like this:

@DaskStream.register_api()
class to_kafka(DaskStream, core.to_kafka):
    def update(self, x, who=None, metadata=None):
        client = default_client()
        result = client.submit(to_kafka.update, self, x, who, metadata)
        yield self._emit(result)

However, there's still the issue of the Kafka connection. It seems Dask attempts to pickle the Kafka producer and push it the worker. This fails due to the Confluent producer using some sort of lazy instantiation. In my previous attempt to make this work, I was able to create the producer using the getattr workaround. It also attaches the producer to the worker in order to maintain the connection.

def get_producer(config):
    w = get_worker()
    if hasattr(w, 'producer'):
        return w.producer

    import confluent_kafka as ck
    w.producer = getattr(ck, 'Producer')(config)
    return w.producer

This seems very much like a hack to me, and I would prefer a better solution. If anyone has more expertise on Dask, any help would be appreciated.

Lenguaje dominante
Python
Estrellas
1.3k
Forks
149
Merge medio
17 h 39 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-streamz/streamz

Todos los issues de python-streamz/streamz

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.