forked from platypush/platypush
Don't serialize I/O wrappers
This removes warnings on `config.get`, where the `logging` configuration key may also contain the current logging stream and we end up with a JSONDecodeError when trying to serialize it.
This commit is contained in:
parent
ba31dff06a
commit
334ccc35a2
1 changed files with 5 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import decimal
|
import decimal
|
||||||
import datetime
|
import datetime
|
||||||
|
import io
|
||||||
import logging
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
@ -66,6 +67,10 @@ class Message:
|
||||||
if isinstance(obj, JSONAble):
|
if isinstance(obj, JSONAble):
|
||||||
return obj.to_json()
|
return obj.to_json()
|
||||||
|
|
||||||
|
# Don't serialize I/O wrappers/objects
|
||||||
|
if isinstance(obj, io.IOBase):
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return super().default(obj)
|
return super().default(obj)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in a new issue