[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Pavel Aborilov
scoped_session use threads only if you dont use scopefunc. On Saturday, February 15, 2014 2:05:33 AM UTC+4, Jonathan Vanasco wrote: > > I don't know if any of this will help - I'm too tired to read though all > your code: > > 1. Twisted isn't threadsafe, so anything happening in deferToThread nee

[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Jonathan Vanasco
I don't know if any of this will help - I'm too tired to read though all your code: 1. Twisted isn't threadsafe, so anything happening in deferToThread needs to be entirely encapsulated. This has totally screwed me up many times. You should avoid a scoped_session , as it has to do with thread

[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-14 Thread Pavel Aborilov
In Twisted there is a great thing known as `ContextTracker`: > provides a way to pass arbitrary key/value data up and down a call > stack without passing them as parameters to the functions on that call > stack. In my twisted web app in method `render_GET` I set a `uuid` parameter: call = co

[sqlalchemy] Re: Twisted + SQLAlchemy

2014-02-13 Thread Pavel Aborilov
now, I'm using it like this: @defer.inlineCallbacks def jsonrpc_get(self, id): self.log.debug("get device with id %s" % id) device = yield deferToThread(self.devices.get, id) // then generate output from device, where device is ORM object if devices.get method I use sc