Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A gevent and REDIS based queue for creating a MixPanel event with Python.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
README.mkd
mixevent.py
mixpanel.py
sample_redis_call.py
start.sh

README.mkd

Introduction

This is a basic sample that shows how to create a queue for processing events to MixPanel.

We build the event and push it to a REDIS queue, then consume the task through a gevent based worker which will run "forever" popping tasks off the REDIS queue and submitting them to MixPanel - this way you can have a very high performing queue that's asynchronous and won't slow down your main code waiting for MixPanel to respond.

There are two files:

  • mixpanel.py - Contains two main functions, build_event which builds a dictionary containing the event and properties you want to pass to MixPanel and track which logs the event after it is popped off the REDIS queue to mixpanel.

I was going to combine the REDIS logic into the build_event, but left this out (although I've included a sample) because you might want to use mixevent.py with your own queuing system (Celery for example).

  • mixevent.py - A gevent based worker that will run indefinitely, popping MixPanel events off a REDIS queue and submitting them to MixPanel.

Requirements

To run this successfully, you'll need:

Running the mixevent.py worker

There is a start.sh script included, if you start the worker like this:

$ start.sh mixevent.py &

It will happily run in the background, shutting itself down every 1000 events and restarting without dropping a beat. We run them like this in production - they are very long running processes and will keep happily chugging away without a hiccup.

Something went wrong with that request. Please try again.