Giter VIP home page Giter VIP logo

processpy's Introduction

Python Process Manager (processpy)

processpy is simple process manager for python. If you want to run multiple process for the same function, this tool is for you.

  • You can run multiple process of the same function concurrently.
  • You can choose to kill previous running process before running a new process of the same function.
  • You can choose to ignore new process of the same function if it's already running.

Installation

pip install processpy

Example (No concurrency and no previous kill)

from processpy import ProcessManager
import time

def sum(a, b):
    time.sleep(30)
    print(a+b)

sum_process = ProcessManager(sum, kill_previous=False, concurrent_running=False)
sum_process.run({'a': 10, 'b': 20})
time.sleep(5)

"""
The following will not run. Because concurrent run is false and kill previous is also false. So, it will simply return with doing nothing and let the previous run.
"""
sum_process.run({'a': 10, 'b': 20}) 

Example (No concurrency but with previous kill)

from processpy import ProcessManager
import time

def sum(a, b):
    time.sleep(30)
    print(a+b)

sum_process = ProcessManager(sum, kill_previous=True, concurrent_running=False)
sum_process.run({'a': 10, 'b': 20})
time.sleep(5)

"""
The following will kill the previous unfinished process and run. Because concurrent run is false and kill previous is True. So, it will simply kill the previous unfinished process. If previous one is already finished, nothing to kill. 
"""
sum_process.run({'a': 10, 'b': 20}) 

Example (with concurrency)

from processpy import ProcessManager
import time

def sum(a, b):
    time.sleep(30)
    print(a+b)

sum_process = ProcessManager(sum, concurrent_running=True)
sum_process.run({'a': 10, 'b': 20})
time.sleep(5)

"""
The following will run alongside of the previous process. 
"""
sum_process.run({'a': 10, 'b': 20}) 

You can also kill the running process (if concurrent_running=False )

sub_process.kill()

processpy's People

Contributors

nazmulnnb avatar

Stargazers

 avatar

Watchers

 avatar

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.