py.test database issues

36 views
Skip to first unread message

Mark Graves

unread,
Mar 3, 2015, 10:21:46 AM3/3/15
to web...@googlegroups.com
I've been encountering some strange issues that I have never seen before.

I'm running some a complete regression suite on an application. It's pretty long running, in the current iteration. (over 400 seconds).

This includes a number of browser automation tasks using python and selenium.

For anyone familiar with py.test,

I'm using a fixture to grab access to the database to make sure the logic is working properly.

Namely:

from gluon.shell import env

from gluon.storage import Storage

@pytest.fixture()

def db():

    web2py_env = env(appname, import_models=True)

    web2py_env = Storage(web2py_env)

    db = web2py_env.db

    return db

When I use a sqlite database, I'm encountering lock issues, on a query where there really shouldn't be lock issues.

It's a simple delete query, run before a test to ensure the appropriate table is empty.

psuedocode:

db(db.table.id>0).delete()
driver.get(url)

When running this separately as a test, or within a group of tests, it works fine, no lock issues.

When running this in the full regression, I'm getting database lock issues.

Then I switched to postgres for testing (I know -- cheap and dirty, but I wanted to see if that was really the issue).

So, then I started getting even stranger errors from gluon.contrib.pg8000

namely:

NoData Object
Msg Query Idle Object

etc. etc.

In the course of testing, I've seen basically every one of the possible pg8000 errors in the source.

Anyone have any clues as to where I might be able to track down the source?

Is it a thread issue, where I should have done from gluon import current and then set the db in the function?

I'm wondering if this is something to do with pytest's internals or web2py's or my own code.

Any thoughts would be greatly appreciated.


Richard Vézina

unread,
Mar 3, 2015, 11:53:03 AM3/3/15
to web2py-users
without the exact test code difficult to say, but in what you shows, I would have put a db.commit() after the db(db.table.id>0).delete()...

And this may easily explained the lock of db.

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Massimo Di Pierro

unread,
Mar 3, 2015, 12:02:43 PM3/3/15
to web...@googlegroups.com
Can you try psycopg2 instead of pg8000.

Mark Graves

unread,
Mar 3, 2015, 12:26:20 PM3/3/15
to web...@googlegroups.com
Hey Richard,

Thanks! I did actually have that commit.

I know its hard to say..

Thanks Massimo,

I will try psycopg2 and let you all know if it continues.

-Mark

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/WFAB-yKIygg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages