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

Streaming Error #46

Open
rsadr opened this issue Jan 16, 2025 · 1 comment
Open

Streaming Error #46

rsadr opened this issue Jan 16, 2025 · 1 comment

Comments

@rsadr
Copy link

rsadr commented Jan 16, 2025

Running Jupiter notebook example for "Streaming Example" in jupyter_demo.ipynb, I get the error below. I think asyncio library is needed?

INFO:Schwabdev.Stream:Connecting to streaming server...


RuntimeError Traceback (most recent call last)
Cell In[10], line 3
1 #start stream and send request
2 streamer.start(add_to_list)
----> 3 streamer.send(streamer.level_one_equities("AMD", "0,1,2,3,4,5,6,7,8"))

File ~/newenv/lib/python3.12/site-packages/schwabdev/stream.py:219, in Stream.send(self, requests)
213 """
214 Send a request to the stream
215 :param requests: list of requests or a single request
216 :type requests: list | dict
217 """
218 # send the request using the async function
--> 219 asyncio.run(self.send_async(requests))

File /usr/lib/python3.12/asyncio/runners.py:190, in run(main, debug, loop_factory)
161 """Execute the coroutine and return the result.
162
163 This function runs the passed coroutine, taking care of
(...)
186 asyncio.run(main())
187 """
188 if events._get_running_loop() is not None:
189 # fail fast with short traceback
--> 190 raise RuntimeError(
191 "asyncio.run() cannot be called from a running event loop")
193 with Runner(debug=debug, loop_factory=loop_factory) as runner:
194 return runner.run(main)

RuntimeError: asyncio.run() cannot be called from a running event loop

INFO:Schwabdev.Stream:Connected to streaming server.
ERROR:Schwabdev.Stream:no close frame received or sent
WARNING:Schwabdev.Stream:Stream has crashed within 90 seconds, likely no subscriptions, invalid login, or lost connection (not restarting).

@tylerebowers
Copy link
Owner

The streamer is not really designed to be used in a notebook (even though it is in the example). I will be looking into this over the next couple days.

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

No branches or pull requests

2 participants