"UnsupportedTypeError: The _thread.RLock object found" using logging library


#1

Please see the following notebook https://gist.github.com/lancelote/d1c74fbe8406e1b6b18172c6d4e59b3f (would be great to allow *.datalore attachments btw). Trying to execute it leads to the following error

Traceback (most recent call last):
  at cell 5, line 1
  at cell 4, line 2, in main
  at cell 3, line 2, in get_stats
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 1306, in info
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 1442, in _log
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 1452, in handle
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 1514, in callHandlers
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 861, in handle
  at /opt/anaconda3/envs/datalore-user/lib/python3.6/logging/__init__.py, line 812, in acquire
  at datalore/core/serialization/objects/utils.py, line 31, in __getattr__
UnsupportedTypeError: The _thread.RLock object found. Cannot pass it's state through a cell separator. Please use this object in the same cell where it was created.

It works fine if I merge everything into one cell or comment out logging calls though.


#2

Meanwhile, is logging library supposed to work on Datalore or should I stick to prints?


#3

At the moment Datalore kernel doesn’t support some data types and UnsupportedTypeError is thrown in such cases:

UnsupportedTypeError: The _thread.RLock object found. Cannot pass it’s state through a cell separator. Please use this object in the same cell where it was created.

You should put all the usages of such an object within a single block to make it work, but that might make little sense for logger, so probably it is better to use print in your case.

PS: we’re going to support other kernel types, so you’ll be able to work with any objects – stay tuned in :wink:


#4

Got it, thank you!