Skip to content
Snippets Groups Projects
Commit 4bf5776b authored by Gavin M. Roy's avatar Gavin M. Roy Committed by GitHub
Browse files

Merge pull request #20 from dave-shawley/propagate-exceptions

Propagate exceptions from PoolManager.add.
parents 6af14d56 fe232bde
No related branches found
No related tags found
No related merge requests found
Copyright (c) 2014 - 2015 Gavin M. Roy
Copyright (c) 2014 - 2016 Gavin M. Roy
All rights reserved.
 
Redistribution and use in source and binary forms, with or without modification,
Loading
Loading
Loading
Loading
@@ -47,7 +47,7 @@ master_doc = 'index'
 
# General information about the project.
project = u'Queries'
copyright = u'2014 - 2015, Gavin M. Roy'
copyright = u'2014 - 2016, Gavin M. Roy'
 
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Loading
Loading
Version History
===============
- 1.8.10 2016-06-14
- Propagate PoolManager exceptions from TornadoSession (#20) - Fix by Dave Shawley
- 1.8.9 2015-11-11
- Move to psycopg2cffi for PyPy support
- 1.7.5 2015-09-03
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ The core `queries.Queries` class will automatically register support for UUIDs,
Unicode and Unicode arrays.
 
"""
__version__ = '1.8.4'
__version__ = '1.8.10'
version = __version__
 
import logging
Loading
Loading
Loading
Loading
@@ -312,8 +312,14 @@ class TornadoSession(session.Session):
 
else:
 
# Add the connection to the pool
self._pool_manager.add(self.pid, connection)
try:
# Add the connection to the pool
self._pool_manager.add(self.pid, connection)
except Exception as error:
LOGGER.exception('Failed to add %r to the pool', self.pid)
future.set_exception(error)
return
self._pool_manager.lock(self.pid, connection, self)
 
# Added in because psycopg2ct connects and leaves the
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ classifiers = ['Development Status :: 5 - Production/Stable',
'Topic :: Software Development :: Libraries']
 
setup(name='queries',
version='1.8.4',
version='1.8.10',
description="Simplified PostgreSQL client built upon Psycopg2",
maintainer="Gavin M. Roy",
maintainer_email="gavinmroy@gmail.com",
Loading
Loading
Loading
Loading
@@ -175,6 +175,27 @@ class SessionConnectTests(testing.AsyncTestCase):
self.obj._exec_cleanup(mock.Mock(), 14)
self.assertNotIn(14, self.obj._futures)
 
def test_pool_manager_add_failures_are_propagated(self):
futures = []
def add_future(future, callback):
futures.append((future, callback))
obj = tornado_session.TornadoSession()
obj._ioloop = mock.Mock()
obj._ioloop.add_future = add_future
future = concurrent.Future()
with mock.patch.object(obj._pool_manager, 'add') as add_method:
add_method.side_effect = pool.PoolFullError(mock.Mock())
obj._create_connection(future)
self.assertEqual(len(futures), 1)
connected_future, callback = futures.pop()
connected_future.set_result(True)
callback(connected_future)
self.assertIs(future.exception(), add_method.side_effect)
 
class SessionPublicMethodTests(testing.AsyncTestCase):
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment