Git Product home page Git Product logo

Comments (7)

danpaquin avatar danpaquin commented on May 20, 2024

Hello @yogamurthy --

Thanks for letting us know. Would you please share with us the environment details as well as the fill script you are running? Thanks!

from coinbasepro-python.

yogamurthy avatar yogamurthy commented on May 20, 2024

OS: Windows 7
Python: tried in both 2.7 and 3.6

The following is the complete script im using now

import GDAX, time
class myWebsocketClient(GDAX.WebsocketClient):
def onOpen(self):
self.url = "wss://ws-feed.gdax.com/"
self.products = ["LTC-USD"]
self.MessageCount = 0
print("Lets count the messages!")
def onMessage(self, msg):
print("Message type:", msg["type"], "\t@ %.3f" % float(msg["price"]))
self.MessageCount += 1
if(self.MessageCount >= 100):
exit()
def onClose(self):
print("-- Goodbye! --")

wsClient = myWebsocketClient()
wsClient.start()
print(wsClient.url, wsClient.products)
while (wsClient.MessageCount < 500):
print("\nMessageCount =", "%i \n" % wsClient.MessageCount)
time.sleep(1)

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024

Hi @yogamurthy - Firstly, I would like to state I did not encounter this issue on my current Python interpreters, but I will do my best to help you out given the information on hand.

Under initial inspection of your script, it seems as though you are missing the last line here:

wsClient.close()

...but you said it exits with the 'Goodbye!' message, so I'm going to assume you have this line. Additionally, it would be better practice to change the onMessage method to the code following. While it didn't change the behavior, it might be a better way to implement a fix to your issue. The message count & close logic was to show how you might share variables between threads so feel free to modify this to suit your needs.

self.MessageCount += 1
if self.MessageCount >= 100 and 'type' in msg:
     print("Message type:", msg)

Please let me know if you have any additional questions!

from coinbasepro-python.

jwlondon98 avatar jwlondon98 commented on May 20, 2024

I have been getting a similar issue on my mac

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024

Hi @jwlondon98 thank you for sharing your issue! Hopefully we can get this cleared up ASAP. Did the fixes above work? Are you getting the same error? What version of the project are you running?

from coinbasepro-python.

pretzel729 avatar pretzel729 commented on May 20, 2024

My scripts have also been crashing near the end of any implementations of WebsocketClient.
I had been receiving a segmentation fault (core dump) error.
It happened most of the time but not all of the time. So probably a multithreading issue.
I think sometimes it was possible for the websocket connection in WebsocketClient to be called (in the secondary thread) after the socket had already closed (in the main thread).

If we join to the second thread after self.stop = True,but before self.ws.close(), the websocket connection can't close while the secondary thread is running.

In def close(self) of WebsocketClient.py:
Old code:
def close(self):
...
self.onClose()
self.stop = True
# self.thread = None
self.ws.close()

Proposed code:
def close(self):
...
self.onClose()
self.stop = True
# self.thread = None
self.thread.join()
self.ws.close()

from coinbasepro-python.

danpaquin avatar danpaquin commented on May 20, 2024

This has been implemented in the most recent update to PyPI

@yogamurthy I will be closing this out within the next week -- please let us know if you encounter the same error with these changes.

from coinbasepro-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.