项目作者: Vrekrer

项目描述 :
Decorators for easy threading in Python
高级语言: Python
项目地址: git://github.com/Vrekrer/threading_decorators.git
创建时间: 2017-05-23T13:27:48Z
项目社区:https://github.com/Vrekrer/threading_decorators

开源协议:MIT License

下载


threading_decorators

Decorators for easy threading in Python

Usage

Use Threaded_Function as a decorator for any function

  1. import threading_decorators as ThD
  2. @ThD.Threaded_Function
  3. def foo(my_arg, my_keyword_arg=100):
  4. # Do something
  5. print(my_arg)
  6. for i in range(my_keyword_arg):
  7. # Do something else
  8. ThD.check_stop()
  9. print(i)

Then call the function to rut it inside a Thread

  1. foo('Test')

if check_stop() where used inside the function, then calling the stop method will stop the execution of the function at the next check_stop() point

  1. foo.stop()