Skip to content

Commit aa201b3

Browse files
committed
bug fixes
1 parent 2fbf821 commit aa201b3

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ target/
5656
.DS_Store
5757

5858
# example app private files
59-
isstreamer.ini
59+
isstreamer.ini
60+
61+
example_app/unpublished/*

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* added a wait time based on the `Retry-After` header responded by the API when a `429` response is received
77
* using Initial State API >=0.0.4
88

9-
0.0.26 (unreleased)
9+
0.0.26
1010
-------------------
1111

1212
* bubbling up exception for 402 responses from api to be clearer.

ISStreamer/Streamer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,12 @@ def __ship(retry_attempts, wait=0):
131131
response = conn.getresponse()
132132

133133
if (response.status >= 200 and response.status < 300):
134-
self.console_message("ship: " + str(response.status), level=2)
135-
self.console_message("ship: headers: " + str(response.msg), level=2)
136-
self.console_message("ship: body: " + str(response.read()), level=2)
134+
self.console_message("ship: status: " + str(response.status) + "\nheaders: " + str(response.msg), level=2)
135+
self.console_message("ship: body: " + str(response.read()), level=3)
137136
elif (response.status == 401 or response.status == 403):
138137
self.console_message("ERROR: unauthorized access_key: " + self.AccessKey)
139138
elif (response.status == 402):
140-
self.console_message("AccessKey exceeded limit for month, check account at www.initialstate.com/app")
139+
self.console_message("AccessKey exceeded limit for month, check account at https://app.initialstate.com/#/account")
141140
raise Exception("PAYMENT_REQUIRED")
142141
elif (response.status == 429):
143142
if "Retry-After" in response.msg:
@@ -203,8 +202,9 @@ def flush(self):
203202
self.console_message("flush: queue empty...", level=2)
204203
if len(messages) > 0:
205204
self.console_message("flush: queue not empty, shipping", level=2)
205+
206206
self.ship_messages(messages)
207-
self.console_message("flush: finished flushing queue", level=2)
207+
self.console_message("flush: finished flushing queue", level=2)
208208

209209

210210
def log_object(self, obj, key_prefix=None, epoch=None):
@@ -265,8 +265,9 @@ def __ship_buffer():
265265
if (not self.Offline):
266266
if (len(self.LogQueue) >= self.BufferSize):
267267
self.console_message("log: queue size approximately at or greater than buffer size, shipping!", level=10)
268-
268+
self.console_message("log: async is {state}".format(async=self.Async))
269269
if (self.Async):
270+
self.console_message("log: spawning ship thread", level=3)
270271
t = threading.Thread(target=__ship_buffer)
271272
t.daemon = False
272273
t.start()

example_app/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from ISStreamer.Streamer import Streamer
22
import time
33

4-
streamer = Streamer(bucket_name="test", debug_level=2, ini_file_location="./isstreamer.ini", async=False)
4+
streamer = Streamer(bucket_name="test", debug_level=3, ini_file_location="./isstreamer.ini", async=True)
55

66
def stress_test_loop(i, num):
77
while i > 0:
88
streamer.log("iterations_left_{n}".format(n=num), i)
9-
time.sleep(.2)
9+
time.sleep(.1)
10+
streamer.flush()
1011
i = i - 1
1112

1213

13-
stress_test_loop(50, 1)
14+
stress_test_loop(5000, 1)
1415

1516
streamer.close()

0 commit comments

Comments
 (0)