Code

Opened 2 years ago

Closed 14 months ago

#17066 closed Bug (fixed)

Exception TypeError when using GeoIP

Reported by: mitar Owned by: nobody
Component: GIS Version: 1.4
Severity: Normal Keywords:
Cc: mmitar@…, stefanw Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using GeoIP in my code I am getting such error at the end of syncdb call:

Exception TypeError: "'NoneType' object is not callable" in <bound method GeoIP.__del__ of <django.contrib.gis.utils.geoip.GeoIP object at 0x103a35690>> ignored

It seems there is some race condition? I am using Python 2.7.2 on Mac OS X. It has threaded support enabled. Django 1.3. python-geoip 1.2.5, libgeoip 1.4.7.

Attachments (1)

geoiptest.zip (7.0 KB) - added by stefanw 14 months ago.
GeoIP Test Project

Download all attachments as: .zip

Change History (10)

comment:1 Changed 2 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

This looks similar to #13488 and #13843.

comment:2 Changed 2 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by robbyd

+1 I am getting this bug as well. Django 1.3.1

comment:4 Changed 20 months ago by anonymous

  • Version changed from 1.3 to 1.4

Same here after migrating to Django 1.4.1

comment:5 Changed 20 months ago by claudep

It could be useful if anyone could provide us with a basic project where this error can be reproduced.

comment:6 Changed 19 months ago by claudep

  • Resolution set to needsinfo
  • Status changed from new to closed

Changed 14 months ago by stefanw

GeoIP Test Project

comment:7 Changed 14 months ago by stefanw

  • Cc stefanw added
  • Resolution needsinfo deleted
  • Status changed from closed to new

I can confirm this on Django 1.4.3 with geoip 1.4.8.

I attached a test project that should reproduce this error. Instructions: Extract, install requirements (Django==1.4.3) and run runtest.sh which downloads GeoIP country data (slightly too big to attach) and then does a syncdb (any Django command will do).

The exception should be the last line of the output. The culprit is obviously in django.contrib.gis.geoip.base.GeoIP.__del__ where GeoIP_delete is None when this method is called.

Replacing __del__ with the following removes the exception, but may leave file handles lying around (I have no deeper knowledge about that).

def __del__(self):
    # Cleaning any GeoIP file handles lying around.
    if GeoIP_delete is None:
        return
    if self._country: GeoIP_delete(self._country)
    if self._city: GeoIP_delete(self._city)

comment:8 Changed 14 months ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

Thanks for the research on that issue. I guess that we might have difficulties to come with a test for this, so I suggest to simply add the if GeoIP_delete is None safeguard, and call it a day!

comment:9 Changed 14 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 35185495e3f70f900b542bf95d744f51e5c5cb92:

Fixed #17066 -- Prevented TypeError in GeoIP.del

When garbaging GeoIP instances, it happens that GeoIP_delete is
already None.
Thanks mitar for the report and stefanw for tests.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.