Skip to content

unexpected behavior of isinstance on distributed results #2228

@bluenote10

Description

@bluenote10

Using isinstance on computation results from Dask.Distributed shows unexpected behavior under Python 2.7:

import dask
from dask.distributed import Client


class MyObject(object):
    pass


print("Expected behavior:")
x = MyObject()
print(x, type(x), isinstance(x, MyObject))

print("Behavior with debugging scheduler:")
dask.config.set(scheduler="single-threaded")
x_delayed = dask.delayed(lambda: MyObject())()
x = dask.compute(x_delayed)[0]
print(x, type(x), isinstance(x, MyObject))

print("Behavior with distributed scheduler:")
client = Client()
x_delayed = dask.delayed(lambda: MyObject())()
x = dask.compute(x_delayed)[0]
print(x, type(x), isinstance(x, MyObject))

Output:

Expected behavior:
(<__main__.MyObject object at 0x7fa9afe49d50>, <class '__main__.MyObject'>, True)
Behavior with debugging scheduler:
(<__main__.MyObject object at 0x7fa9afe49f10>, <class '__main__.MyObject'>, True)
Behavior with distributed scheduler:
(<__main__.MyObject object at 0x7fa9a6ef4790>, <class '__main__.MyObject'>, False)

In this simple example isinstance(x, MyObject) seems to be always False with distributed. In a more complex example the results are even non-deterministic.

The problem does not exist with the non-distributed schedulers or when using Python 3.5.2.

Versions:

  • Python 2.7.12
  • dask==0.19.0
  • distributed==1.23.0
  • tornado==5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions