mixpanel/mixpanel-python — pull request #11 by jessepollak (2014-01-18 22:07:38+00:00)
Title: Adds asynchronous buffered consumer to available consumers

I was disappointed by the lack of an asynchronous consumer in the default Mixpanel library, so I decided to write one (based off of the [Segment.io Client class](https://github.com/segmentio/analytics-python), which I thought had a good thread-based flushing model). I thought it could be potentially useful to other Mixpanel users.

An AsyncBufferedConsumer behaves similar to a BufferedConsumer, except for a few key differences:

- By default, all flushes to the Mixpanel API are done in a separate Thread, meaning that flushes are non-blocking (useful for a Request/Response cycle). This can be overridden by calling `flush(async=False)` at any time.
- By default, the AsyncBufferedConsumer automatically flushes the event queues upon receiving an event if the last flush was more than a certain amount of time ago. This setting is configured by the `flush_after` parameter to the class.

This PR provides the class and a full suite of accompanying unit tests to verify correct behavior.

I'd love to hear what y'all think!