pathwaycom/pathway · error · ValueError

You can't use the same ConnectorSubject object in more than

Error message

You can't use the same ConnectorSubject object in more than one Python connector.If you want to use the same ConnectorSubject twice, create two separate objects of this class.

What it means

Raised by pw.io.python.read when the ConnectorSubject instance passed in has already been used by another Python connector (guarded by an internal _already_used flag). Subjects carry per-connector runtime state, so sharing one object across two reads would interleave buffers and lifecycle callbacks; Pathway requires a fresh instance per connector.

Source

Thrown at python/pathway/io/python/__init__.py:600

    >>> pw.debug.compute_and_print(table, include_id=False)
    a | b
    0 | x0
    1 | x1
    2 | x2
    3 | x3
    """

    if format is None:
        format = "json"  # previous default
    else:
        warnings.warn(
            "Setting `format` in Python connector is deprecated."
            + " Please just pass values of proper types to the `next` method.",
            DeprecationWarning,
        )

    if subject._already_used:
        raise ValueError(
            "You can't use the same ConnectorSubject object in more than one Python connector."
            + "If you want to use the same ConnectorSubject twice, create two separate objects of this class."
        )
    subject._already_used = True
    subject._pw_format = format

    data_format_type = get_data_format_type(format, SUPPORTED_INPUT_FORMATS)

    if data_format_type == "identity":
        if format == "binary":
            schema = RawDataSchema
        else:
            schema = PlaintextDataSchema
        if subject._with_metadata is True:
            schema |= MetadataSchema

    schema = assert_schema_not_none(schema, data_format_type)
    return table_from_datasource(

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Instantiate a new subject per connector: pw.io.python.read(MySubject(), schema=S1, ...); pw.io.python.read(MySubject(), schema=S2, ...).
  2. If the source is genuinely shared, read it once into one table and fork with Pathway table operations (select/filter/join) instead of two connectors.
  3. In tests, create the subject inside the test/fixture function rather than at module level.

Example fix

# before
subject = MySubject()
pw.io.python.read(subject, schema=S1)
pw.io.python.read(subject, schema=S2)  # ValueError

# after
pw.io.python.read(MySubject(), schema=S1)
pw.io.python.read(MySubject(), schema=S2)
Defensive patterns

Strategy: validation

Validate before calling

pw.io.python.read(MySubject(), schema=S1)   # fresh instance each time
pw.io.python.read(MySubject(), schema=S2)

Prevention

When it happens

Trigger: Reusing a module-level subject instance: subject = MySubject(); pw.io.python.read(subject, schema=S1, ...); pw.io.python.read(subject, schema=S2, ...) in the same process (including two branches of one pipeline).

Common situations: Fan-out patterns where the same upstream feed should feed two tables; refactorings that hoist subject creation to module scope for reuse; test suites that build pipelines in a loop with a shared fixture subject without resetting between cases.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/8a73196b13587c1b. Report an issue: GitHub.