python - how to thread a function from an imported library -


i've been working on python program syntax of python still relatively new me. example, if have 2 python files contents below, what's proper way thread function?

main.py - file being executed

#!/usr/bin/env python  #threading array threads = []  import threading import anotherfile af  afcheck = af.init() #return true or false if afcheck == true:      threads.append(threading.thread(target=af.listener))  try:     thread in threads:         thread.start() except (keyboardinterrupt, systemexit):     print("closing shop");     thread in threads:         thread.cancel()     sys.exit() 

i going write dummy code anotherfile.py, seems pretty inconsequential. i've been able test point i've seen isn't executing listener , i'm not sure proper way call it. maybe need thread listener inside of anotherfile.py, thought simplicities sake, nice have them in 1 place since have multiple imports.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -