Skip to content

Commit 77a0b2e

Browse files
author
Kenneth Chan
committed
SDKPYTHON-11 add qsize param in client object
1 parent 28972af commit 77a0b2e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# The short X.Y version.
5252
version = '0.6'
5353
# The full version, including alpha/beta/rc tags.
54-
release = '0.6.1'
54+
release = '0.6.2'
5555

5656
# The language for content autogenerated by Sphinx. Refer to documentation
5757
# for a list of supported languages.

predictionio/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__copyright__ = "Copyright 2013, TappingStone, Inc."
1010
__license__ = "Apache License, Version 2.0"
1111

12-
__version__ = "0.6.1"
12+
__version__ = "0.6.2"
1313

1414

1515
# import packages
@@ -90,19 +90,21 @@ class Client:
9090
9191
9292
"""
93-
def __init__(self, appkey, threads=1, apiurl="http://localhost:8000", apiversion = ""):
93+
def __init__(self, appkey, threads=1, apiurl="http://localhost:8000", apiversion = "", qsize=0):
9494
"""Constructor of Client object.
9595
9696
:param appkey: the appkey
9797
:param threads: number of threads for handling requests
9898
:param apiurl: the PredictionIO API URL path.
9999
:param apiversion: the PredictionIO API version. (optional) (eg. "", or "/v1")
100+
:param qsize: the request queue size
100101
101102
"""
102103
self.appkey = appkey
103104
self.threads = threads
104105
self.apiurl = apiurl
105106
self.apiversion = apiversion
107+
self.qsize = qsize
106108

107109
# check connection type
108110
https_pattern = r'^https://(.*)'
@@ -117,7 +119,7 @@ def __init__(self, appkey, threads=1, apiurl="http://localhost:8000", apiversion
117119
self.host = m.group(1)
118120

119121
self._uid = None # identified uid
120-
self._connection = Connection(host=self.host, threads=self.threads, https=self.https)
122+
self._connection = Connection(host=self.host, threads=self.threads, qsize=self.qsize, https=self.https)
121123

122124
def close(self):
123125
"""Close this client and the connection.

tests/predictionio_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@ def test_pending_requests(self):
222222

223223
client.close()
224224

225+
def test_qsize(self):
226+
client = predictionio.Client(APP_KEY, 1, API_URL, qsize=10)
227+
228+
client.identify("u222")
229+
for i in range(100):
230+
client.arecord_action_on_item("like", str(i))
231+
232+
n = 1
233+
while n > 0:
234+
n = client.pending_requests()
235+
time.sleep(0.1)
236+
print n
237+
238+
client.close()
239+
225240

226241

227242
"""

0 commit comments

Comments
 (0)