Hey original developer pyfarm-master here, Guido pointed me at this thread. 
 I've run a test with a3af638e1a95d42075e25e874746 and the sqlite tests are 
still failing to drop the tables:

https://travis-ci.org/pyfarm/pyfarm-master/builds/59341150


Since Guido commented however I merged a PR he proposed and that seems to 
have fixed most of our other failures (everything except for the drop 
tables issue with sqlite).  I started to think there's something different 
with respect to sqlite and wrote this which does almost exactly what the 
tests do (and it always works):

import os
os.environ.update(
    PYFARM_DATABASE_URI="sqlite:///:memory:"
)

from pyfarm.master.application import db

for i in range(5):
    # setUp
    from pyfarm.models.agent import Agent
    from pyfarm.models.job import Job
    from pyfarm.models.jobtype import JobType
    from pyfarm.models.software import (
        Software, SoftwareVersion, JobSoftwareRequirement,
        JobTypeSoftwareRequirement)
    from pyfarm.models.tag import Tag
    from pyfarm.models.task import Task
    from pyfarm.models.user import User
    from pyfarm.models.jobqueue import JobQueue
    from pyfarm.models.gpu import GPU
    db.create_all()

    # execute tests

    # tearDown
    db.session.remove()
    db.drop_all()


There's a gist of the above here for those who have issues displaying the 
above properly: https://gist.github.com/opalmer/0850879794e81198c3a0

If you run a test individually, it also always works:

env PYFARM_DATABASE_URI="sqlite:///:memory:" nosetests 
tests/test_models/test_model_users.py:UserTest.test_user_auth_token


However if you run something that requires a few test iterations it almost 
always fails when dropping the tables:
 

env PYFARM_DATABASE_URI="sqlite:///:memory:" nosetests 
tests/test_models/test_model_users.py:UserTest 


I say "almost always fails" because on occasion the above will pass too. 
 I'm only using the above test case as an example but other tests seem to 
have the same problem.

So I got to thinking about what we're doing differently with sqlite and 
this bit of code comes to mind:


    # sqlite specific configuration for development
    if db.engine.name == "sqlite":
        @event.listens_for(Engine, "connect")
        def set_sqlite_pragma(dbapi_connection, connection_record):
            cursor = dbapi_connection.cursor()
            cursor.execute("PRAGMA foreign_keys=ON")
            cursor.execute("PRAGMA synchronous=OFF")
            cursor.execute("PRAGMA journal_mode=MEMORY")
            cursor.close()


If I comment the above out in our application.py 
<https://github.com/pyfarm/pyfarm-master/blob/f22912cd7d89b93c146801fd1575ff06f4883724/pyfarm/master/application.py#L208>
 module 
the second nosetests example above works without issues.  Here's a test on 
travis with sqlalchemy 1.0.0 and the above code commented out:

https://travis-ci.org/pyfarm/pyfarm-master/builds/59345110


And from the latest master (didn't expect a difference here but wanted to 
be sure):

https://travis-ci.org/pyfarm/pyfarm-master/builds/59346659


And here's the same tests with the same code above commented out with 
sqlalchemy 0.9.9

https://travis-ci.org/pyfarm/pyfarm-master/builds/59346146


 
So I'm not sure yet if this is a bug in sqlalchemy 1.0.0+ or not because I 
didn't dive that deeply into the code changes for event handling. 
 Regardless, I think this is probably something we should update in our 
tests anyway since we could couple the execution of those pragma statements 
more closely with the tests as they run to avoid the issue in the future. 
 I would be curious to know if this is actually a bug in event handling 
though.

---Oliver

On Monday, April 20, 2015 at 7:22:47 PM UTC-4, Michael Bayer wrote:
>
>
>
> On 4/20/15 12:56 PM, Guido Winkelmann wrote: 
> > I just tested, the problem is still present in the current master 
> > (bd61e7a3287079cf742f4df698bfe3628c090522 from github). Guido W. 
>
> can you please try current master at least as of 
> a3af638e1a95d42075e25e874746, thanks. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to