OK, so what's not working?
On Fri, Feb 16, 2018 at 10:55 AM, wrote:
> Yes session.is_active is True.
> I really sure, because i log this operation.
>
> пятница, 16 февраля 2018 г., 13:50:51 UTC+3 пользователь Simon King написал:
>>
>> You haven't explained in what way
Yes session.is_active is True.
I really sure, because i log this operation.
пятница, 16 февраля 2018 г., 13:50:51 UTC+3 пользователь Simon King написал:
>
> You haven't explained in what way it's not working with your latest
> iteration.
>
> The last code you posted only called session.close()
You haven't explained in what way it's not working with your latest iteration.
The last code you posted only called session.close() if
session.is_active was true. Are you sure you really are closing the
session?
Simon
On Fri, Feb 16, 2018 at 10:02 AM, wrote:
> This
Maybe you try to change same rows within several concurrent requests? I do
not use mssql, but in postgres it is normal.
Anyway it is normal behavior. One transaction tries to change a row,
another one tries to change the same. When the first transaction commited,
the second can continue its job.
This option does not suit me.
My app based on CherryPy 3.2.2.
I add more logging, and all session closing by
session.close()
in finally section.
I can't understand why this not work...
четверг, 15 февраля 2018 г., 18:07:49 UTC+3 пользователь Антонио Антуан
написал:
>
> You need just that:
> from
You need just that:
from proj.core import Session
@app.teardown_request
def clear_session():
Session.remove()
Session created with scoper_session, of course. We do not use
flask-sqlalchemy package, just flask and separated sqlalchemy.
чт, 15 февр. 2018 г., 16:28 Simon King
When you say your first execute function doesn't work, what do you
mean? Do you get an error? Do the results not show up in the database?
I don't think there's any need for session.begin()
http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.begin
Simon
On
Hello, Simon!
Where did you read that I was using Flask?
I just write about it like example few posts ago.
Anyway.
I try another variant without decorator - just execute function
def execute(statement, **kwargs):
session = SESSION()
session.begin(subtransactions=True)
kwargs['tries'] =
Personally I wouldn't use decorators for this. I would make every
function that needs to interact with the database take an explicit
session parameter, and I would use the facilities of the web framework
to create the session at the beginning of the request and close it at
the end. I've never used
Hello, Simon!
So what better way?
Something like this?
SESSION = sessionmaker(bind=engine, autocommit=True)
@decorator_with_args
def session_decorator(func, default=None):
def wrapper(*a, **kw):
session = SESSION()
session.begin(subtransactions=True)
if 'session' not
I think there are a couple of problems with this.
1. You are calling scoped_session and sessionmaker every time the
decorated function is called, which is unnecessary. sessionmaker
returns a factory function for creating sessions, so you typically
only have one sessionmaker() call in your
Decorator like this
engine = create_engine(
'mssql+pymssql://{LOGIN}:{PASSWORD}@{HOST}/{DATABASE}?charset={CHARSET}={TIMEOUT}'.format(**DATABASE),
isolation_level='READ COMMITTED'
)
def decorator_with_args(decorator_to_enhance):
"""
https://habrahabr.ru/post/141501/
"""
The pattern you should be aiming for is one in which a fresh
transaction is started for every web request that touches the
database, and that the transaction is closed at the end of the
request. How are you ensuring that at the moment?
Simon
On Wed, Feb 14, 2018 at 12:51 PM,
If I run tests where all functions run one-by-one - all tests passed.
But when i run web app and functions can call almost in parallel then i
have a problem, then there are problems - transactions can block each other.
I tried to set the isolation level of SNAPSHOT and READ COMMITTED, but it
did
Hello, Mike!
In my web app i have many selects like
session.execute(select([table1]).where(condition))
and not so much updates, inserts and deletes like
session.execute(update(table1).where(condition).values(**values))
session.execute(insert(table1).values(**values))
On Sat, Jan 27, 2018 at 5:49 AM, Евгений Рымарев
wrote:
> I receive this error:
> This result object does not return rows. It has been closed automatically.
there's a lot of weird situations which can cause that error, usually
when using a connection that has had some
I receive this error:
This result object does not return rows. It has been closed automatically.
суббота, 27 января 2018 г., 1:09:53 UTC+3 пользователь Mike Bayer написал:
>
> On Fri, Jan 26, 2018 at 4:21 PM, Евгений Рымарев
> wrote:
> > Hello, everyone!
> > Engine:
I use mssql 2017 with compatibility level = 100 (mssql 2008).
I enable ALLOW_SNAPSHOT_ISOLATION and READ_COMMITTED_SNAPSHOT, but that not
solve a problem.
When i run application via python manage.py (one thread) all works normal.
суббота, 27 января 2018 г., 1:09:53 UTC+3 пользователь Mike Bayer
On Fri, Jan 26, 2018 at 4:21 PM, Евгений Рымарев
wrote:
> Hello, everyone!
> Engine:
> engine = create_engine(
>
> 'mssql+pymssql://{LOGIN}:{PASSWORD}@{HOST}/{DATABASE}?charset={CHARSET}'.format(**DATABASE),
> isolation_level='READ COMMITTED'
> )
>
>
> My first
Hello, everyone!
Engine:
engine = create_engine(
'mssql+pymssql://{LOGIN}:{PASSWORD}@{HOST}/{DATABASE}?charset={CHARSET}'.format(**DATABASE),
isolation_level='READ COMMITTED'
)
My first decorator for session:
@decorator_with_args
def session_decorator(func, default=None):
def
20 matches
Mail list logo