Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
0b530bf4
Commit
0b530bf4
authored
Nov 20, 2009
by
Joshua Roesslein
Browse files
The streaming API Stream object can be run either in async/synch modes. See CHANGELOG for details.
parent
eb1d8bb8
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
0b530bf4
...
...
@@ -4,6 +4,14 @@ during upgrade will be listed here.
1.3 -> 1.4 [Future release]
===========================
+ Added people search API method. API.search_users()
+ Streaming API
- Moved parameters into POST body to prevent "head too big" errors.
- Stream can be run either asynchronously (threaded) or synchronously (blocks main thread).
By default Stream will run in sync. mode. To change this pass into the stream
method 'async=True'. Example:
s = Stream('test', 'password', MyListener())
s.sample(async=True) # threaded mode
s.filter(track=['pizza']) # synch./blocking mode
1.2 -> 1.3 [Current release]
=====================
...
...
tweepy/streaming.py
View file @
0b530bf4
...
...
@@ -144,32 +144,36 @@ class Stream(object):
if
self
.
listener
.
on_limit
(
json
.
loads
(
data
)[
'limit'
][
'track'
])
==
False
:
self
.
running
=
False
def
firehose
(
self
,
count
=
None
):
def
_start
(
self
,
async
):
self
.
running
=
True
if
async
:
Thread
(
target
=
self
.
_run
).
start
()
else
:
self
.
_run
()
def
firehose
(
self
,
count
=
None
,
async
=
False
):
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%i/statuses/firehose.json?delimited=length'
%
STREAM_VERSION
if
count
:
self
.
url
+=
'&count=%s'
%
count
self
.
running
=
True
Thread
(
target
=
self
.
_run
).
start
()
self
.
_start
(
async
)
def
retweet
(
self
):
def
retweet
(
self
,
async
=
False
):
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%i/statuses/retweet.json?delimited=length'
%
STREAM_VERSION
self
.
running
=
True
Thread
(
target
=
self
.
_run
).
start
()
self
.
_start
(
async
)
def
sample
(
self
,
count
=
None
):
def
sample
(
self
,
count
=
None
,
async
=
False
):
if
self
.
running
:
raise
TweepError
(
'Stream object already connected!'
)
self
.
url
=
'/%i/statuses/sample.json?delimited=length'
%
STREAM_VERSION
if
count
:
self
.
url
+=
'&count=%s'
%
count
self
.
running
=
True
Thread
(
target
=
self
.
_run
).
start
()
self
.
_start
(
async
)
def
filter
(
self
,
follow
=
None
,
track
=
None
):
def
filter
(
self
,
follow
=
None
,
track
=
None
,
async
=
False
):
params
=
{}
self
.
headers
[
'Content-type'
]
=
"application/x-www-form-urlencoded"
if
self
.
running
:
...
...
@@ -180,8 +184,7 @@ class Stream(object):
if
track
:
params
[
'track'
]
=
','
.
join
(
map
(
str
,
track
))
self
.
body
=
urllib
.
urlencode
(
params
)
self
.
running
=
True
Thread
(
target
=
self
.
_run
).
start
()
self
.
_start
(
async
)
def
disconnect
(
self
):
if
self
.
running
is
False
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment