Giter Site home page Giter Site logo

needle's Introduction

Needle

Why?

Implementing threading certainly is a headache when it comes to small projects. this library aims to minimize the time wasted implementing threading using predefined techniques that suites most of the common cases allowing software developers to focus on what is important

Installation

To install the latest github release

$ git clone https://github.com/BitTheByte/Needle
$ cd Needle
$ python setup.py install

Using pip

$ pip install needlepy

Examples

import needle
import requests

needle.LOGGER = 3 # 0 = DISABLE LOGGING, 1 = ERROR, 2 = WARNING, 3 = INFO 

hosts = [
    ("https://indeed.com",),
    ("https://google.com",),
    ("https://facebook.com",),
    ("https://yahoo.com",)
]

def main():
    for i in needle.GroupWorkers(target=requests.get, arguments=hosts, concurrent=2, kernel='needlpy'):
        print(i.arguments, i._return )

    # see https://stackoverflow.com/questions/51828790/what-is-the-difference-between-processpoolexecutor-and-threadpoolexecutor
    for i in needle.GroupWorkers(target=requests.get, arguments=hosts, concurrent=2, kernel='threadpoolexecutor'):
        print(i.arguments, i._return )

    for i in needle.GroupWorkers(target=requests.get, arguments=hosts, concurrent=2, kernel='processpoolexecutor'):
        print(i.arguments, i._return )

if __name__ == '__main__':
    main()

Needle supports muliple threading techniques other than shown at the example for more examples and techniques see /examples

Issues

if you have a suggestion or encountered any errors please open a new issue under https://github.com/bitthebyte/needle/issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.