Skip to content

Commit

Permalink
Merge pull request #9 from joshland/master
Browse files Browse the repository at this point in the history
Patch: fix async for 3.7, running without async masks exceptions.
  • Loading branch information
trallard committed May 2, 2019
2 parents d8771a8 + 6c77569 commit 83380d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
18 changes: 15 additions & 3 deletions solutions/etl-basic/stream_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# ------------------------------------------------------------------

# Import libraries needed
import sys
import json
import time
from configparser import ConfigParser
Expand Down Expand Up @@ -203,7 +204,6 @@ def start_stream(stream, **kwargs):


if __name__ == "__main__":

create_table(DATABASE, "tweets")
# first we need to authenticate
twitter = connectTwitter()
Expand All @@ -213,6 +213,18 @@ def start_stream(stream, **kwargs):
myStream = tweepy.Stream(auth=twitter.auth, listener=myStreamListener, timeout=30)

# stream tweets using the filter method
start_stream(myStream, track=["python", "pycon", "jupyter", "#pycon2019"], async=True)

version = float(f"{sys.version_info[0]}.{sys.version_info[1]}")
if version >= 3.7:
kwargs = {
'track': ["python", "pycon", "jupyter", "#pycon2019"],
'is_async': True
}
else:
kwargs = {
'track': ["python", "pycon", "jupyter", "#pycon2019"],
'async': True
}
pass
start_stream(myStream, **kwargs)
pass

16 changes: 15 additions & 1 deletion solutions/etl-basic/stream_twitter_alt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# ------------------------------------------------------------------

# Import libraries needed
import sys
import json
import time
from configparser import ConfigParser
Expand Down Expand Up @@ -255,4 +256,17 @@ def start_stream(stream, **kwargs):
myStream = tweepy.Stream(auth=twitter.auth, listener=myStreamListener, timeout=30)

# stream tweets using the filter method
start_stream(myStream, track=["python", "pycon", "jupyter", "#pycon2019"], async=True)
version = float(f"{sys.version_info[0]}.{sys.version_info[1]}")
if version >= 3.7:
kwargs = {
'track': ["python", "pycon", "jupyter", "#pycon2019"],
'is_async': True
}
else:
kwargs = {
'track': ["python", "pycon", "jupyter", "#pycon2019"],
'async': True
}
pass
start_stream(myStream, **kwargs)
pass

0 comments on commit 83380d8

Please sign in to comment.