Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 200a3bb

Browse files
committed
Removed superflous _qo member from FlaskPooledHypertable.
FlaskPooledHypertable constructor now takes an optional ``q`` override.
1 parent b8fba10 commit 200a3bb

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Here you can find the recent changes to Flask Hypertable.
2121
:tags: project
2222

2323
Added HYPERTABLE_TIMEOUT_MSECS option (defaults to 5000 msecs)
24+
Removed superflous _qo member from FlaskPooledHypertable
25+
FlaskPooledHypertable constructor now takes an optional ``q``
26+
override.
2427

2528
.. changelog::
2629
:version: 0.2.0

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ TODO
55
dev
66
---
77

8+
* include libHyperPython somehow?
9+
810
* extend ManagedThriftClient with mutator creation helpers
911

1012
* ORM? Draw on MongoKit, MongoEngine, SQLAlchemy as inspiration

flask_hypertable/flask_hypertable.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from Queue import Queue, Empty, Full
1212
from hypertable.thriftclient import ThriftClient
13-
from flask import current_app
1413
from thrift.transport import TTransport
1514

1615
# Find the stack on which we want to store the database connection.
@@ -114,20 +113,23 @@ class FlaskPooledHypertable(FlaskHypertable):
114113
HYPERTABLE_MAX_OVERFLOW: 10
115114
"""
116115

117-
# the connection pool
116+
# a queue like collection
118117
_q = None
119118

120-
# the overflow pool
121-
_qo = None
122-
123119
pool_size = 1
124120
pool_overflow = 0
125121
overflow_count = 0
126122

127-
def init_app(self, app):
123+
def init_app(self, app, q=None):
124+
"""
125+
:param q the queue to use, optional. If not, then a queue
126+
of type ``Queue.Queue`` is created.
127+
The queue must be thread safe and conform
128+
to the ``Queue.Queue``interface.
129+
"""
128130
FlaskHypertable.init_app(self, app)
129131

130-
self._q = self._qo = None
132+
self._q = None
131133

132134
app.config.setdefault('HYPERTABLE_POOL_SIZE', 5)
133135
app.config.setdefault('HYPERTABLE_MAX_OVERFLOW', 10)
@@ -140,9 +142,10 @@ def init_app(self, app):
140142
elif self.pool_overflow < 0:
141143
raise ValueError("Please specify HYPERTABLE_MAX_OVERFLOW >= 0")
142144

143-
self._q = Queue(maxsize=self.pool_size)
144-
if self.pool_overflow > 0:
145-
self._qo = Queue(maxsize=self.pool_overflow)
145+
if q is None:
146+
self._q = Queue(maxsize=self.pool_size)
147+
else:
148+
self._q = q
146149

147150
def close_app(self):
148151
""" shutdowns this instance, forcibly closing all opened

0 commit comments

Comments
 (0)