Skip to content

Commit b3c6c90

Browse files
committed
open conn, if closed and calling send
1 parent eaa7edd commit b3c6c90

6 files changed

Lines changed: 16 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ A python client for sending SQL queries and receive results from BoilingData Web
1313
> **NOTE:** This package is considered experimental. Feel free to suggest improvements, especially on how to make this module easy to use.
1414
1515
```python
16+
import os
1617
import asyncio
1718
from py_boilingdata import BoilingData
1819

20+
# os.environ["BD_USERNAME"] = "yourBoilingAccountUsername"
21+
# os.environ["BD_PASSWORD"] = "yourBoilingPassword"
22+
1923
async def main():
2024
boiling = BoilingData()
2125
await boiling.connect()

main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import asyncio
22
from py_boilingdata import BoilingData
33

4+
# os.environ["BD_USERNAME"] = "yourBoilingAccountUsername"
5+
# os.environ["BD_PASSWORD"] = "yourBoilingPassword"
6+
47

58
async def main():
69
boiling = BoilingData()

py_boilingdata/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def _get_credentials(self):
189189
return self.aws_creds
190190

191191
async def _ws_send(self, msg):
192+
if not self.bd_is_open:
193+
await self.connect()
192194
self.logger.debug(f"> {msg}")
193195
return self.ws_app.send(msg)
194196

@@ -204,11 +206,12 @@ def _on_msg(self, ws_app, data):
204206
return
205207
msg_type = msg.get("messageType")
206208
if msg_type == "LOG_MESSAGE":
209+
message = msg.get("logMessage")
207210
log_level = msg.get("logLevel")
208211
if log_level == "ERROR":
209-
raise Exception(msg.get("logMessage"))
212+
raise Exception(message)
210213
if log_level == "INFO":
211-
self.logger.info(msg.get("logMessage"))
214+
self.logger.info(message)
212215
if msg_type == "INFO" and self.log_level == "INFO":
213216
self.logger.info(msg.get("info"))
214217
if msg_type == "LAMBDA_EVENT":

py_boilingdata/data_queue.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,17 @@ def _have_all_parts(self):
4949
subBatch["data"] = data
5050
else:
5151
batchCounter["data"] = data
52-
# print(
53-
# f"RequestId {self.requestId}:\n\t"
54-
# + f"Batches {len(self.batchCounters)}/{totalBatches}"
55-
# )
5652
self.have_new_messages = False
5753
if len(self.batchCounters) < totalBatches:
5854
return False
5955
for value in self.batchCounters.values():
6056
totalSubBatches = value.get("totalSubBatches")
6157
if totalSubBatches:
62-
# print(f"\tsubBatches: {len(value.get('subBatches'))}/{totalSubBatches}")
6358
if len(value.get("subBatches")) < totalSubBatches:
6459
return False
6560
for value in value.get("subBatches").values():
6661
totalSplits = value.get("totalSplits")
6762
if totalSplits:
68-
# print(f"\tsplits: {len(value.get('splits'))}/{totalSplits}")
6963
if len(value.get("splits")) < totalSplits:
7064
return False
7165
self.parts_done = True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ asyncio_mode = "auto"
33

44
[tool.poetry]
55
name = "py-boilingdata"
6-
version = "0.2.5"
6+
version = "0.2.6"
77
description = "BoilingData (websockets) client for Python"
88
authors = ["Dan Forsberg <dan@boilingdata.com>"]
99
readme = "README.md"

tests/test_connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def cb(resp):
6262
q = "SELECT first_name, email FROM parquet_scan('s3://boilingdata-demo/test.parquet') LIMIT 1"
6363
await boiling.execute(q, cb) # only awaits as long as the request is dispatched
6464
await asyncio.sleep(5) # let them race...
65-
assert data == [{"email": "ajordan0@com.com", "first_name": "Amanda"}]
65+
assert data == [{"email": "ajordan0@com.com", "first_name": "Amanda"}] or data == [
66+
{"email": "ajordan0@com.com"}
67+
]
6668

6769

6870
# @pytest.mark.asyncio

0 commit comments

Comments
 (0)