Hi Werner,

The problems seems to have to do with sqlalchemy, if I only close the database sessions then it hangs, I have to do:

self.engine = db.sa.create_engine(dburl, encoding='utf8', echo=False)
self.Session = db.sao.sessionmaker(autoflush=True, transactional=True)
self.ds = self.Session()
...  application does whatever and then on close I do
# if I don't do the del's app does not close
del self.ds
del self.Session
del self.engine

I am checking with the SA list why this is necessary, I probably am doing something wrong somewhere along the lines.

Doing the del's will invoke the garbage-collection and the finalizers on those objects. So I guess that in their finalization, they close for instance some db-connection. The db-connection(-pool) could open native OS threads, and keep them alive as long as the connection(-pool) isn't closed.

That would also explain why you can't list the threads with threading.enumerate().

Which database do you use? How hard is it to switch to a different DB backend for testing purposes, to see if the drivers for that DB behave differently?




Anyhow thanks for the tips.

You're welcome.