Hello everybody, i want to use SqlAlchemy in a thread but i have a problem. Here two files :

*Orm.py*
# -*- coding: ISO-8859-15 -*-
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.sql import func, exists
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm.query import Query
# from sqlalchemy.types import *
engine = create_engine("mysql://root:@localhost/alertesms")
Base = declarative_base()

class compte(Base):
    __tablename__ = 'compte'
    codeCompte  = Column('codeCompte', Integer, primary_key=True)
    serveurMail = Column('serveurMail', String)
    portMail = Column('portMail', Integer)
    ssl = Column('ssl', Integer)
    loginMail = Column('loginMail', String)
    motDePasseMail = Column('motDePasseMail', String)
    tel1 = Column('tel1', String)
    credit = Column('credit', Integer)
    def __init__(self,
    serveurMail="",
    portMail=0,
    ssl=0,
    loginMail="",
    motDePasseMail="",
    tel1="",
    credit=10):
        self.serveurMail=serveurMail
        self.portMail=portMail
        self.ssl=ssl
        self.loginMail=loginMail
        self.motDePasseMail=motDePasseMail
        self.tel1=tel1
        self.credit=credit

class Query(Query):
    def __init__(self, *arg, **kw):
       self._populate_existing = True
       super(Query, self).__init__(*arg, **kw)

def get_scoped_session():
return scoped_session(sessionmaker(autocommit=False, autoflush=False, expire_on_commit=False, bind=engine, query_cls=Query))

def get_session():
    scoped_session = get_scoped_session()
    return scoped_session()

session = get_scoped_session()

*Surveillance.py*
# -*- coding: ISO-8859-15 -*-
import time
import threading
import ExtractionMail
import Orm

class SyncTopAppel(threading.Thread):
    """ Déclencheur des tops d'exécution """
    def __init__(self):
        threading.Thread.__init__(self)
        self.running = False
    def run(self):
        self.running = True
        while self.running:
            print "debut"
            self.session = Orm.get_session()
            print self.session
*            # print self.session.query(Orm.compte)*
            print "fin"
            time.sleep(1)
    def stop(self):
        self.running = False




All is fine but when i remove comment line in my thread, the thread block and the prints doesn t continue ^^



why?

Chris

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

<<attachment: moz-screenshot-2.png>>

<<attachment: moz-screenshot-3.png>>

Reply via email to