python的干净简单的任务并发性。

runium的Python项目详细描述


runium

PyPI version shields.ioPyPI pyversionsDocumentation StatusGitHub license

runium是一个python库,它使编写非阻塞代码变得容易, 异步任务。

您可以随意添加新任务,选择何时和如何执行它们 threadsprocesss并附加回调,以便在 任务已完成运行。将这些任务运行一次或定期,或计划为 在特定时间运行它们。

runium的目的是做这些简单,容易和干净的,最少 代码没有更改。只需要一行代码。

文档https://runium.readthedocs.io/en/latest/main.html

pypi:https://pypi.org/project/runium/

功能

  • concurrency:在自己的线程或进程中运行任务一次或多次。
  • 重复:以偶数时间间隔定期运行任务。在一定的时间内可以选择。
  • 调度:在特定日期和时间运行任务。
  • callbacks:runium任务可以接受在任务完成运行时执行的回调函数。
  • 简单性和可读性:在一行易于阅读的代码中完成以上所有操作。

安装

runium分布在pypi上。最好的安装方法是使用pip:

$ pip install runium

快速启动

fromrunium.coreimportRunium# Initialize Runiumrn=Runium()# Or you may want to run your tasks in Processesrn=Runium(mode='multiprocessing')# Create a taskasync_task=rn.new_task(task)# Attach callbacks (Check the documentation for callbacks)async_task.on_finished(callback)# or you can be more flexible...async_task.on_success(s_callback).on_error(e_callback)# Run it. This will return a future object.future=async_task.run()# Or if you want to run it multiple timesfuture=async_task.run(times=3)# Or maybe run it 3 times every 1 hourfuture=async_task.run(every='1 hour',times=3)# Or tell Runium to start the task in a specific timefuture=async_task.run(start_in='5 hours')# Then you can wait for the result.future.result()# Of course you can do all these in one line :)rn.new_task(task).run(every='1 second',times=3).result()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何向第二个组合框模型项添加数组值从第一个组合框所选项获取数组名称?   使用Java与WebSphere的SSL握手错误   eclipse线程“main”Java中的第一个Java程序异常。lang.NoClassDefFoundError   java将Javafx应用作为Web应用移植的最佳方式   IDE的java右JVM文件夹   java如何在基本适配器中停止文本到语音   java If block使用substring和equals方法以假值执行   在本例中,如何在java中返回多个值?   java第二个主类在maven构建期间覆盖第一个主类   如何在java中设置运行时ArrayList的泛型类型?   java从主机读取文件