diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bcfdfe0f..190aa438 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,3 +20,10 @@ Development information (for developing this module itself) 1. Run tests: You'll need redis running locally on its default port of 6379. $ py.test testing + +Developing with different python versions +----------------------------------------- + +Example for switching to python 3: + +```virtualenv -p `which python3` ~/.virtualenvs/python-client``` \ No newline at end of file diff --git a/demo/demo.py b/demo/demo.py index ca9b580e..fde40f1f 100644 --- a/demo/demo.py +++ b/demo/demo.py @@ -10,7 +10,7 @@ ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.DEBUG) -formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +formatter = logging.Formatter('%(asctime)s - %(name)s:%(lineno)d - %(levelname)s - %(message)s') ch.setFormatter(formatter) root.addHandler(ch) diff --git a/ldclient/event_consumer.py b/ldclient/event_consumer.py index 5131e3f4..2a57419d 100644 --- a/ldclient/event_consumer.py +++ b/ldclient/event_consumer.py @@ -1,9 +1,9 @@ from __future__ import absolute_import import errno -import json from threading import Thread +import jsonpickle import requests from requests.packages.urllib3.exceptions import ProtocolError @@ -42,12 +42,15 @@ def do_send(should_retry): body = [events] else: body = events + + json_body = jsonpickle.encode(body, unpicklable=False) + log.debug('Sending events payload: ' + json_body) hdrs = _headers(self.sdk_key) uri = self._config.events_uri r = self._session.post(uri, headers=hdrs, timeout=(self._config.connect_timeout, self._config.read_timeout), - data=json.dumps(body)) + data=json_body) r.raise_for_status() except ProtocolError as e: inner = e.args[1] diff --git a/requirements.txt b/requirements.txt index 5d3cfbe1..0f5587f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ CacheControl>=0.10.2 requests>=2.10.0 sseclient>=0.0.12 future>=0.15.2 -strict-rfc3339>=0.7 \ No newline at end of file +strict-rfc3339>=0.7 +jsonpickle==0.9.3 \ No newline at end of file