Skip to content Skip to sidebar Skip to footer

Threading An Infinite Loop

def check_incoming_messages_to_client(incoming_chat_messages,uri_str, kill_threads_subscript): global kill_threads messaging = Pyro4.Proxy(uri_str) while(TRUE):

Solution 1:

Thread(target=check_incoming_messages_to_client(incoming_chat_messages[length-1],uri_str, kill_threads_subscript))calls your function, then passes the result as the target (except since it never ends, no result ever materializes, and you never even construct the Thread).

You want to pass the function uncalled, and the args separately so the thread calls it when it runs, rather than the main thread running it before the worker thread even launches:

t1 = Thread(target=check_incoming_messages_to_client,
            args=(incoming_chat_messages[length-1], uri_str, kill_threads_subscript))

Post a Comment for "Threading An Infinite Loop"