diff --git a/platypush/message/__init__.py b/platypush/message/__init__.py index 7c7a009fd..28879b1a9 100644 --- a/platypush/message/__init__.py +++ b/platypush/message/__init__.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod import decimal import datetime +import io import logging import inspect import json @@ -66,6 +67,10 @@ class Message: if isinstance(obj, JSONAble): return obj.to_json() + # Don't serialize I/O wrappers/objects + if isinstance(obj, io.IOBase): + return None + try: return super().default(obj) except Exception as e: