All Projects → ranaroussi → Multitasking

ranaroussi / Multitasking

Licence: apache-2.0
Non-blocking Python methods using decorators

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Multitasking

Pebble
Multi threading and processing eye-candy.
Stars: ✭ 276 (+217.24%)
Mutual labels:  threading, decorators, multiprocessing
Fooproxy
稳健高效的评分制-针对性- IP代理池 + API服务,可以自己插入采集器进行代理IP的爬取,针对你的爬虫的一个或多个目标网站分别生成有效的IP代理数据库,支持MongoDB 4.0 使用 Python3.7(Scored IP proxy pool ,customise proxy data crawler can be added anytime)
Stars: ✭ 195 (+124.14%)
Mutual labels:  async, threading, multiprocessing
Codejam
Set of handy reusable .NET components that can simplify your daily work and save your time when you copy and paste your favorite helper methods and classes from one project to another
Stars: ✭ 217 (+149.43%)
Mutual labels:  async, threading
atpbar
Progress bars for threading and multiprocessing tasks on terminal and Jupyter Notebook
Stars: ✭ 74 (-14.94%)
Mutual labels:  multiprocessing, threading
mantichora
A simple interface to Python multiprocessing and threading
Stars: ✭ 13 (-85.06%)
Mutual labels:  multiprocessing, threading
Babel Plugin Mobx Deep Action
Reduces `action` and `runInAction` boilerplates
Stars: ✭ 110 (+26.44%)
Mutual labels:  async, decorators
Process
An async process dispatcher for Amp.
Stars: ✭ 119 (+36.78%)
Mutual labels:  async, multiprocessing
python-graceful-shutdown
Example of a Python code that implements graceful shutdown while using asyncio, threading and multiprocessing
Stars: ✭ 109 (+25.29%)
Mutual labels:  multiprocessing, threading
Tutorials
机器学习相关教程
Stars: ✭ 9,616 (+10952.87%)
Mutual labels:  threading, multiprocessing
polog
Логирование должно быть красивым
Stars: ✭ 26 (-70.11%)
Mutual labels:  decorators, threading
Async Techniques Python Course
Async Techniques and Examples in Python Course
Stars: ✭ 314 (+260.92%)
Mutual labels:  async, threading
Open.channelextensions
A set of extensions for optimizing/simplifying System.Threading.Channels usage.
Stars: ✭ 106 (+21.84%)
Mutual labels:  async, threading
Joblib
Computing with Python functions.
Stars: ✭ 2,620 (+2911.49%)
Mutual labels:  threading, multiprocessing
Asyncawaitbestpractices
Extensions for System.Threading.Tasks.Task and System.Threading.Tasks.ValueTask
Stars: ✭ 693 (+696.55%)
Mutual labels:  async, threading
React Native Multithreading
🧵 Fast and easy multithreading for React Native using JSI
Stars: ✭ 164 (+88.51%)
Mutual labels:  threading, multiprocessing
funboost
pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和全球一切知名消息队列中间件,python函数加速器,框架包罗万象,一统编程思维,兼容50% python编程业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数。旧名字是function_scheduling_distributed_framework
Stars: ✭ 351 (+303.45%)
Mutual labels:  multiprocessing, threading
think-async
🌿 Exploring cooperative concurrency primitives in Python
Stars: ✭ 178 (+104.6%)
Mutual labels:  multiprocessing, threading
Vs Threading
The Microsoft.VisualStudio.Threading is a xplat library that provides many threading and synchronization primitives used in Visual Studio and other applications.
Stars: ✭ 585 (+572.41%)
Mutual labels:  async, threading
Aiomultiprocess
Take a modern Python codebase to the next level of performance.
Stars: ✭ 1,070 (+1129.89%)
Mutual labels:  async, multiprocessing
Kotlin Futures
A collections of extension functions to make the JVM Future, CompletableFuture, ListenableFuture API more functional and Kotlin like.
Stars: ✭ 79 (-9.2%)
Mutual labels:  async

MultiTasking: Non-blocking Python methods using decorators

.. image:: https://img.shields.io/badge/python-2.7,%203.5+-blue.svg?style=flat :target: https://pypi.python.org/pypi/multitasking :alt: Python version

.. image:: https://img.shields.io/travis/ranaroussi/multitasking/master.svg? :target: https://travis-ci.org/ranaroussi/multitasking :alt: Travis-CI build status

.. image:: https://img.shields.io/pypi/v/multitasking.svg?maxAge=60 :target: https://pypi.python.org/pypi/multitasking :alt: PyPi version

.. image:: https://img.shields.io/pypi/status/multitasking.svg?maxAge=2592000 :target: https://pypi.python.org/pypi/multitasking :alt: PyPi status

.. image:: https://img.shields.io/pypi/dm/multitasking.svg?maxAge=2592000 :target: https://pypi.python.org/pypi/multitasking :alt: PyPi downloads

.. image:: https://www.codefactor.io/repository/github/ranaroussi/multitasking/badge :target: https://www.codefactor.io/repository/github/ranaroussi/multitasking :alt: CodeFactor

.. image:: https://img.shields.io/github/stars/ranaroussi/multitasking.svg?style=social&label=Star&maxAge=60 :target: https://github.com/ranaroussi/multitasking :alt: Star this repo

.. image:: https://img.shields.io/twitter/follow/aroussi.svg?style=social&label=Follow%20Me&maxAge=60 :target: https://twitter.com/aroussi :alt: Follow me on twitter

\

MultiTasking is a tiny Python library lets you convert your Python methods into asynchronous, non-blocking methods simply by using a decorator.

Example

.. code:: python

# example.py
import multitasking
import time
import random
import signal

# kill all tasks on ctrl-c
signal.signal(signal.SIGINT, multitasking.killall)

# or, wait for task to finish on ctrl-c:
# signal.signal(signal.SIGINT, multitasking.wait_for_tasks)

@multitasking.task # <== this is all it takes :-)
def hello(count):
    sleep = random.randint(1,10)/2
    print("Hello %s (sleeping for %ss)" % (count, sleep))
    time.sleep(sleep)
    print("Goodbye %s (after for %ss)" % (count, sleep))

if __name__ == "__main__":
    for i in range(0, 10):
        hello(i+1)

The output would look something like this:

.. code:: bash

$ python example.py

Hello 1 (sleeping for 0.5s)
Hello 2 (sleeping for 1.0s)
Hello 3 (sleeping for 5.0s)
Hello 4 (sleeping for 0.5s)
Hello 5 (sleeping for 2.5s)
Hello 6 (sleeping for 3.0s)
Hello 7 (sleeping for 0.5s)
Hello 8 (sleeping for 4.0s)
Hello 9 (sleeping for 3.0s)
Hello 10 (sleeping for 1.0s)
Goodbye 1 (after for 0.5s)
Goodbye 4 (after for 0.5s)
Goodbye 7 (after for 0.5s)
Goodbye 2 (after for 1.0s)
Goodbye 10 (after for 1.0s)
Goodbye 5 (after for 2.5s)
Goodbye 6 (after for 3.0s)
Goodbye 9 (after for 3.0s)
Goodbye 8 (after for 4.0s)
Goodbye 3 (after for 5.0s)

Settings

The default maximum threads is equal to the # of CPU Cores. This is just a rule of thumb! The Thread module isn't actually using more than one core at a time.

You can change the default maximum number of threads using:

.. code:: python

import multitasking
multitasking.set_max_threads(10)

...or, if you want to set the maximum number of threads based on the number of CPU Cores, you can:

.. code:: python

import multitasking
multitasking.set_max_threads(multitasking.config["CPU_CORES"] * 5)

For applications that doesn't require access to shared resources, you can set MultiTasking to use multiprocessing.Process() instead of the threading.Thread(), thus avoiding some of the GIL constraints <https://jeffknupp.com/blog/2013/06/30/pythons-hardest-problem-revisited/>_.

.. code:: python

import multitasking
multitasking.set_engine("process") # "process" or "thread"

Installation

Install multitasking using pip:

.. code:: bash

$ pip install multitasking --upgrade --no-cache-dir

Install multitasking using conda:

.. code:: bash

$ conda install -c ranaroussi multitasking

Legal Stuff

yfinance is distributed under the Apache Software License. See the LICENSE.txt <./LICENSE.txt>_ file in the release for details.

P.S.

Please drop me an note with any feedback you have.

Ran Aroussi

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].