Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions in on_message are swallowed in Google Colab #94

Open
timborden opened this issue Jan 9, 2025 · 1 comment
Open

Exceptions in on_message are swallowed in Google Colab #94

timborden opened this issue Jan 9, 2025 · 1 comment

Comments

@timborden
Copy link

Here is sample code to reproduce the error in Google Colab:

from coinbase.websocket import WSClient

symbol = "BAT-USD"
num_changes = 10
changes = []

def on_message(message):
  m = json.loads(message)

  if m["channel"] not in ["l2_data", "market_trades"]:
    return

  changes.append(message)

  print(f"{len(changes)} changes logged ({m['channel']})")

  if len(changes) > num_changes / 2:
    raise Exception("Stop")

client = WSClient(on_message=on_message, verbose=True)
client.open()
client.subscribe(product_ids=[symbol], channels=["heartbeats", "level2", "market_trades"])

while len(changes) < num_changes:
  time.sleep(0.1)

client.unsubscribe(product_ids=[symbol], channels=["heartbeats", "level2", "market_trades"])
client.close()
print("Done")
Copy link

github-actions bot commented Jan 9, 2025

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant