Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Program randomly freezes

See original GitHub issue

Hello… I’m using your library and I don’t know why but my program randomly freezes sometimes. My program is pretty simple and is pretty much just copying the code sample you provide @ (actually, your code sample was also freezing when I tried it).

Could it have to do with the version of python I’m using? (2.7.9) I installed TwitterSearch through pip. I hope its not some deadlock issue.

Here’s what I’ve been running:

from TwitterSearch import *
from time import sleep
    tso = TwitterSearchOrder() # create a TwitterSearchOrder object
    tso.set_keywords(['#vr', '-RT']) # let's define all words we would like to have a look for
    tso.set_language('en') # hell no German, I want English!
    tso.set_include_entities(False) # and don't give us all those entity information

    # it's about time to create a TwitterSearch object with our secret tokens
    ts = TwitterSearch(
        consumer_key = 'xxxx',
        consumer_secret = 'xxxx',
        access_token = 'xxxx',
        access_token_secret = 'xxxx'

    # open file for writing
    text_file = open("#vrtest.txt", "w")

    # check when to stop
    iterations = 0
    max_tweets = 100000

    # callback fucntion used to check if we need to pause the program
    def my_callback_closure(current_ts_instance): # accepts ONE argument: an instance of TwitterSearch
        queries, tweets_seen = current_ts_instance.get_statistics()

        if queries > 0 and (queries % 2) == 0: # trigger delay every other query
            print("\nQueries: " + str(queries) + " now sleeping, 1 minute.\n");
            sleep(60) # sleep for 60 seconds

     # this is where the fun actually starts :)
    for tweet in ts.search_tweets_iterable(tso, callback=my_callback_closure):

        current_line = "%s" % ( tweet['text'] )

        iterations = iterations + 1
        print( "i: " + str(iterations) + " - " + tweet['user']['screen_name'] + " tweeted: " + current_line )

        text_file.write(current_line.encode('utf-8', 'ignore') + "\n")

        # wait 1 second every 10 tweets
        if (iterations % 10 == 0):
            print("\nSleeping 1 second.\n")

        if (iterations >= max_tweets):

except TwitterSearchException as e: # take care of all those ugly errors if there are some

    # close file

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

ckoeppcommented, Jun 2, 2016

I’ll look into this once I have a bit of spare time. Thanks for bringing this up again!

Ic3fr0gcommented, May 23, 2016

Hi, your sample code is not working even on Python 3.5. I isolated it to the for statement in

for tweet in ts.search_tweets_iterable(tso):
    print( '@{} tweeted: {}' , ( tweet['user']['screen_name'], tweet['text'] ) )

So I tried fooling around with your API and realized that none of the functions search_tweets() or search_tweets_iterable() work as expected. I too installed TwitterSearch from pip. Gentle reminder that this bug exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows 10 freezes randomly [Solved]
Try these fixes · Update your drivers · Clear your computer's temp files · Adjust your virtual memory · Repair your system files...
Read more >
Fix Windows 10 Computer Keeps Freezing Randomly
Quick Fixes for Windows 10 Computer Freezing Randomly · Fix 1. Free up Disk Space on the System Disk · Fix 2. Disconnect...
Read more >
How to Fix the Windows 10 Freezes Randomly Issue
Launch the Windows Task Manager by pressing the “Ctrl + Shift + Esc” key. If you can open the Task Manager, select the...
Read more >
Windows 10 Freezes Randomly: 4 Easy Solutions to Use
How can I fix random freezes on Windows 10? Update your drivers; Install the missing updates; Change your power settings; Perform a Startup...
Read more >
FIX: Windows 10 Freezes Randomly
Press and hold the Windows key then press the R key to open Run Program. · Type “powercfg.cpl” and press enter. · Click...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found