So I am writing a simple python stream listener using twython (EDIT: python Twitter client library), when runnining the .py the output file-size oscillates between 1 and 5kb. I would like to know what to do to make sure the file keeps getting written to. Below is the code.
class MyStreamer(TwythonStreamer):
def on_success(self, data):
with open(filename,'w')as outfile:
json.dump(data,outfile,indent=4)
outfile.flush()
outfile.close()
def on_error(self, status_code, data):
print(status_code)
stream = MyStreamer(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
stream.statuses.filter(track=input_string)