Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Issue when async streaming #1628

Closed
generousjj opened this issue Jul 24, 2021 · 1 comment
Closed

Issue when async streaming #1628

generousjj opened this issue Jul 24, 2021 · 1 comment
Labels
Discussion This was converted/moved from/to a discussion Invalid This is not valid Question This is a question

Comments

@generousjj
Copy link

generousjj commented Jul 24, 2021

Sorry for messaging here, usually I'm the one answering lots of questions on discord.

I have a stream code that includes:
class Listener(Stream):
async def on_data(self, data):

I get the following issue when running:
/opt/virtualenvs/python3/lib/python3.8/site-packages/tweepy/streaming.py:133: RuntimeWarning: coroutine 'Listener.on_data' was never awaited
self.on_data(line)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

What can I do to fix this? I may have misread the async docs (since it's past 1am my time), but if I haven't this might be a module issue.

Also, how can I handle Stream connection has errored or timed out now that return values are phased out? I am using 4.0.0a.

Sorry and thank you again.

Best,
generousjj

@Harmon758
Copy link
Member

Stream.on_data is not a coroutine. You shouldn't be defining it as one when you override it in your subclass.
If you need it to be asynchronous, consider using AsyncStream instead.

Also, how can I handle Stream connection has errored or timed out now that return values are phased out?

Tweepy now automatically handles reconnecting when the connection errors or times out.
For handling logging of the error, you can override Stream.on_connection_error or configure the the tweepy logger (See https://docs.python.org/3/howto/logging.html and https://docs.python.org/3/library/logging.html).

For code block usage, see https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks.

No need at all to apologize, but in the future, you should use discussions for questions.

@Harmon758 Harmon758 added Invalid This is not valid Question This is a question labels Jul 25, 2021
@tweepy tweepy locked and limited conversation to collaborators Jul 25, 2021
@Harmon758 Harmon758 added the Discussion This was converted/moved from/to a discussion label Jul 25, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Discussion This was converted/moved from/to a discussion Invalid This is not valid Question This is a question
Projects
None yet
Development

No branches or pull requests

2 participants