green-monkey

Use green versions of all possible modules
Download

green-monkey Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Philip Neustrom
  • Publisher web site:
  • http://github.com/philipn/

green-monkey Tags


green-monkey Description

green-monkey is a Python module to use green versions of all possible modules. For use with gevent.Install & Usagepip install green-monkey or, from source, python setup.py installIn addition to installing green_monkey, this will install green versions of all possible modules.Then place the following:import green_monkeygreen_monkey.patch_all()somewhere before any of your normal imports or code.You'll now be using green versions of all modules and the standard library will be patched. You can think of this as an extension of monkey.patch_all() beyond the standard library.Example: greening Django projectFor instance, in a standard WSGI handler for Apache you might do something like this:import os, syssys.path.append('/usr/local/django')os.environ = 'mysite.settings'import green_monkeygreen_monkey.patch_all()import django.core.handlers.wsgiapplication = django.core.handlers.wsgi.WSGIHandler()Or in a Gunicorn config, you might do something like this:bind = "127.0.0.1:"workers = 3worker_class = "gevent"def def_post_fork(server, worker): import green_monkey green_monkey.patch_all()post_fork = def_post_forkand now your Django project is probably green!In general, it's not possible to automatically green an arbitrary codebase, as it may do something like call an external C library which blocks. But for many projects this will work well -- especially for largely self-contained bits of code, e.g. event handlers in django-socketio.Product's homepage


green-monkey Related Software