Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idle postgres connection interferes with some automated testing frameworks #434

Closed
artemp opened this issue Oct 11, 2011 · 4 comments
Closed

Comments

@artemp
Copy link
Member

artemp commented Oct 11, 2011

Using django testing framework, some unit tests were written that generate a basic default map which draws from postgis.

The db connection stays open (due to connection pooling?). While this is good behavior in production, the testing framework creates a test db, runs tests then destroys the test db as the final step. Because mapnik still has an idle postgres connection, the test script throws an exception:

psycopg2.OperationalError: database "test_simple1" is being accessed by other users
DETAIL: There are 1 other session(s) using the database.

It would be nice to have a way to control this connection behavior via the mapnik API.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] see #433 where I experimenting with the connection being closed when the datasource object is deleted rather than when mapnik exits (and releases the Connection Manager). I think the latter behavior is likely ideal, but perhaps we could add keyword arg to the postgis layer to control this....

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Keyword arg added to patch at #433 which maintains current behavior but allows the desired control.

When you set:

persist_connection = false

in the params of one of the postgres layers loaded via xml, then call

del map

and the connection should be closed.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[perrygeo] Setting persist_connection to false appears to work - regardless of using "del map" or not.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] great, applied in r1337

@artemp artemp closed this as completed Oct 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant