Skip to main content

A convenient way to work with websocket data streams

Project description

A convenient way to work with information streaming from websockets, built on top of the Python iterator protocol.

When subscribing to a stream of qualified data I am usually interested in either the latest value i.e. the one I want when I am ready to do something with it or all the values since I last checked.

whereismysock also has a most subscriber which is all with an upper bound to the number of messages it keeps in memory (deleting the eldest first).

>>> from whereismysock import latest
>>> usdjpy = latest("ws://toplevel/USDJPY")
>>> next(usdjpy)
>>> from whereismysock import all
>>> nk225 = all("ws://trades/NK225")
>>> next(nk225)

I like it because it makes “synchronising” different source of information super easy.

>>> hhi = latest("ws://toplevel/HHI")
>>> hsi = latest("ws://toplevel/HSI")
>>> next(zip(hhi, hsi))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for whereismysock, version 2019.6.0
Filename, size File type Python version Upload date Hashes
Filename, size whereismysock-2019.6.0.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page