Skip to content

Instantly share code, notes, and snippets.

@tobych
Last active December 21, 2015 21:59
Show Gist options
  • Save tobych/6372218 to your computer and use it in GitHub Desktop.
Save tobych/6372218 to your computer and use it in GitHub Desktop.
Monkey patch to work around Django #13843
# https://gist.github.com/tobych/6372218
# Monkey patch to work around https://code.djangoproject.com/ticket/13843
import django
from functools import wraps
def discard_exceptions(f):
@wraps(f)
def wrapper(*args, **kwds):
try:
f(*args, **kwds)
except (AttributeError, TypeError):
pass
return wrapper
django.contrib.gis.geos.prototypes.threadsafe.GEOSContextHandle.__del__ = discard_exceptions(django.contrib.gis.geos.prototypes.threadsafe.GEOSContextHandle.__del__)
django.contrib.gis.geos.prototypes.io.IOBase.__del__ = discard_exceptions(django.contrib.gis.geos.prototypes.io.IOBase.__del__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment