2014-10-27 23:29:04 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import threading
|
|
|
|
import wx
|
2015-01-08 15:01:45 +01:00
|
|
|
from pubsub import pub
|
2014-10-27 23:29:04 +01:00
|
|
|
from twython import TwythonRateLimitError
|
|
|
|
import time
|
|
|
|
|
|
|
|
def call_threaded(func, *args, **kwargs):
|
|
|
|
#Call the given function in a daemonized thread and return the thread.
|
|
|
|
def new_func(*a, **k):
|
|
|
|
try:
|
|
|
|
func(*a, **k)
|
|
|
|
except TwythonRateLimitError:
|
2015-01-13 19:31:37 +01:00
|
|
|
pass
|
2014-10-27 23:29:04 +01:00
|
|
|
# except:
|
|
|
|
# pass
|
|
|
|
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
|
|
|
thread.daemon = True
|
|
|
|
thread.start()
|
|
|
|
return thread
|
2015-01-08 15:01:45 +01:00
|
|
|
|
|
|
|
def stream_threaded(func, *args, **kwargs):
|
|
|
|
def new_func(*a, **k):
|
2015-01-13 19:31:37 +01:00
|
|
|
# global session
|
2015-01-08 15:01:45 +01:00
|
|
|
try:
|
2015-01-13 19:31:37 +01:00
|
|
|
func(**k)
|
2015-01-08 15:01:45 +01:00
|
|
|
except:
|
2015-01-13 19:31:37 +01:00
|
|
|
pub.sendMessage("streamError", session=a[0])
|
2015-01-08 15:01:45 +01:00
|
|
|
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
|
|
|
thread.daemon = True
|
|
|
|
thread.start()
|
|
|
|
return thread
|