OK it would be most helpful if you could open an issue on github:

github.com/sqlalchemy/sqlalchemy

and then send a pull request, which I will run through code review in
gerrit.   My own CI can't test this so I will have to rely on your own
testing of the fix to ensure it works for your side.


On Thu, Feb 21, 2019 at 1:10 PM Shakim Mohammed
<[email protected]> wrote:
>
> Sorry for delayed reply.
>
> Sure, I don't mind. Happy to take that up
>
> On Tue, Feb 19, 2019 at 11:48 PM Mike Bayer <[email protected]> wrote:
>>
>> the issue is that the error condition which pool_pre_ping tests is not
>> implemented within the Sybase dialect as a so-called "disconnect"
>> error.    This is part of the larger issue that the Sybase dialect is
>> not supported right now.   if you are interested in doing some
>> maintenance I can set you up with that but ideally the Sybase dialect
>> would be externally maintained as its own project.
>>
>>
>> On Tue, Feb 19, 2019 at 12:36 PM Shakim Mohammed
>> <[email protected]> wrote:
>> >
>> > Hello,
>> >
>> > My use is case to make sure that the sqlalchemy process does not raise 
>> > exception(or 500) after the backend database reboots.
>> >
>> > I tried using pool_pre_ping = True config to get things done but I am 
>> > getting a different error after the reboot happens
>> >
>> > My configuration are:
>> > SqlAlchemy = 1.2.17
>> > FlaskSqlAlchemy = 2.1
>> > Flask = 0.9
>> > Bakend Database = Sybase
>> > python-sybase = 0.39
>> >
>> > Most of the sqlalchemy configuration other then pool_pre_ping=True is set 
>> > to default.
>> >
>> > Here are the logs. Please let me know if there is anything I am doing it 
>> > incorrectly
>> >
>> > Error: myapp.flask_sqlalchemy_model_init: Exception on /resources/search 
>> > [GET]
>> > Traceback (most recent call last):
>> >     File "/sw/external/flask-py27-0.9/lib/python/flask/app.py", line 1687, 
>> > in wsgi_app
>> >         response = self.full_dispatch_request()
>> >     File "/sw/external/flask-py27-0.9/lib/python/flask/app.py", line 1360, 
>> > in full_dispatch_request
>> >         rv = self.handle_user_exception(e)
>> >     File "/sw/external/flask-py27-0.9/lib/python/flask/app.py", line 1358, 
>> > in full_dispatch_request
>> >         rv = self.dispatch_request()
>> >     File "/sw/external/flask-py27-0.9/lib/python/flask/app.py", line 1344, 
>> > in dispatch_request
>> >         return self.view_functions[rule.endpoint](**req.view_args)
>> >     File "/home/user/myapp/resource.py", line 44 in search_resources
>> >         result = db.engine.execute(sql).fetchall()
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/base.py", 
>> > line 2143, in execute
>> >         connection = self.contextual_connect(close_with_result=True)
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/base.py", 
>> > line 2192, in contextual_connect
>> >         self._wrap_pool_connect(self.pool.connect, None),
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/base.py", 
>> > line 2232, in _wrap_pool_connect
>> >         e, dialect, self
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/base.py", 
>> > line 1528, in _handle_dbapi_exception_noconnection
>> >         util.raise_from_cause(sqlalchemy_exception, exc_info)
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/util/compat.py", 
>> > line 296, in raise_from_clause
>> >         reraise(type(exception), exception, tb=exc_tb, cause=cause)
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/base.py", 
>> > line 2228, in _wrap_pool_connect
>> >         return fn()
>> >     File "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/pool.py", 
>> > line 425, in connect
>> >         return _ConnectionFairy._checkout(self)
>> >     File "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/pool.py", 
>> > line 853, in _checkout
>> >         result = pool._dialect.do_ping(fairy.connection)
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/default.py", 
>> > line 505, in do_ping
>> >         cursor.close()
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 431, 
>> > in close
>> >         self._reset()
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 327, 
>> > in _reset
>> >         self._close_ct_cursor
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 438, 
>> > in _close_ct_cursor
>> >         status = self._cmd.ct_cursor(CS_CURSOR_CLOSE)
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 250, 
>> > in _clientmsg_cb
>> >         raise DatbaseError(msg)
>> >     DatabaseError: (Sybase.DatabaseError) Layer: 1, Origin: 1
>> >     ct_cursor(): user api layer: external error: The connection has been 
>> > marked dead.
>> >
>> >     Exception Sybase.DatabaseError: DatabaseError('Layer: 1, Origin: 
>> > 1\\nct_cmd_drop(): user api layer: external error: The connection has been 
>> > marked dead.',) in <bound method Cursor.__del__ of <Sybase.Cursor intance 
>> > at 0x7f9ee88477e8>> ignored
>> >     ERROR:sqlalchemy.pool.QueuePool:Exception during reset or similar
>> >     Traceback (most recent call last):
>> >     File "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/pool.py", 
>> > line 742, in _finalize_fairy
>> >         fairy._reset(pool)
>> >     File "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/pool.py", 
>> > line 929, in _reset
>> >         pool._dialect.do_rollback(self)
>> >     File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/default.py", 
>> > line 486, in do_rollback
>> >         dbapi_connection.rollback(self)
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 1010, in rollback
>> >         self.execute('rollback transaction')
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 1033, in execute
>> >         cursor = self.cursor()
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 1019, in cursor
>> >         return Cursor(self, inputmap, outputmap)
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 321, 
>> > in __init_-
>> >         status, self._cmd = self._owner._conn.ct_cmd_alloc()
>> >     File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 250, 
>> > in _clientmsg_cb
>> >         raise DatabaseError(msg)
>> >     DatabaseError: Layer: 1, Origin: 1
>> >     ct_cmd_alloc(): user api layer: external error: The connection has 
>> > been marked dead
>> >
>> >     ERROR:sqlalchemy.pool.QueuePool:Exception closing connection 
>> > <Sybase.Connection instance at 0x7f9ee87fcb90>
>> >     Traceback (most recent call last):
>> >         File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/pool.py", line 333, 
>> > in _close_connection
>> >             self._dialect.do_close(connection)
>> >         File 
>> > "/sw/external/sqlalchemy-1.2.17/lib/python/sqlalchemy/engine/default.py", 
>> > line 492, in do_close
>> >             dbapi_connection.close()
>> >         File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 955, in close
>> >             status = conn.ct_cancel(CS_CANCEL_ALL)
>> >         File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 250, in _clientmsg_cb
>> >             raise DatabaseError(msg)
>> >     DatabaseError: Layer: 5, Origin: 3
>> >     ct_cancel(): network packet layer: internal net library error: 
>> > Net-Library operation terminated due to disconnect
>> >
>> >     mod_wsgi (pid=18201): Exception occured processing WSGI script
>> >     Traceback (most recent call last):
>> >         File 
>> > "/sw/external/wekzeug-py27-0.8.3/lib/python/werkzeug/wsgi.py", line 513, 
>> > in next
>> >             return self._next()
>> >         File 
>> > "/sw/external/wekzeug-py27-0.8.3/lib/python/werkzeug/wrappers.py", line 
>> > 829, in iter_encoded
>> >             for item in self.response:
>> >         File 
>> > "/sw/external/wekzeug-py27-0.8.3/lib/python/werkzeug/wsgi.py", line 513, 
>> > in next
>> >             return self._next()
>> >         File 
>> > "/sw/external/wekzeug-py27-0.8.3/lib/python/werkzeug/wrappers.py", line 
>> > 829, in iter_encoded
>> >             for item in self.response:
>> >         File "/sw/external/python-sybase-0.39/lib/python/Sybase.py", line 
>> > 250, in _clientmsg_cb
>> >             raise DatabaseError(msg)
>> >     DatabaseError: Layer: 1, Origin: 1
>> >     ct_cmd_drop(): user api layer: external error: The connection has been 
>> > marked dead
>> >
>> > --
>> > SQLAlchemy -
>> > The Python SQL Toolkit and Object Relational Mapper
>> >
>> > http://www.sqlalchemy.org/
>> >
>> > To post example code, please provide an MCVE: Minimal, Complete, and 
>> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
>> > description.
>> > ---
>> > 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 [email protected].
>> > To post to this group, send email to [email protected].
>> > Visit this group at https://groups.google.com/group/sqlalchemy.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> SQLAlchemy -
>> The Python SQL Toolkit and Object Relational Mapper
>>
>> http://www.sqlalchemy.org/
>>
>> To post example code, please provide an MCVE: Minimal, Complete, and 
>> Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full 
>> description.
>> ---
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to