-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd850fa
commit e6209b5
Showing
8 changed files
with
122 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
from improcess.improcess import multi_processing, console_log | ||
import time | ||
|
||
st = 0 | ||
def start(processing_func, data=None, repeat=None, max_process=4): | ||
assert type(max_process) == int, 'max_process value should be an integer' | ||
assert max_process>0, 'max_process value cannot be less than 1' | ||
mp_local = multi_processing(processing_func, max_process=max_process) | ||
global st | ||
st = time.time() | ||
|
||
if data: | ||
processed_data = mp_local.start(data) | ||
return processed_data | ||
|
||
elif repeat: | ||
assert type(repeat) == int, 'repeat value should be an integer' | ||
assert repeat>0, 'repeat value cannot be less than 1' | ||
processed_data = mp_local.start(repeat) | ||
return processed_data | ||
|
||
else: | ||
print(f'data: {data}, repeat: {repeat}') | ||
|
||
def stop(): | ||
raise Exception('stop_process') | ||
|
||
|
||
def elapsed(output=False): | ||
tt = round((time.time()-st), 2) | ||
if output: | ||
print(f'>>> Elapsed time: {tt} sec') | ||
return tt |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
setup( | ||
name = 'improcess', # How you named your package folder (MyLib) | ||
packages = ['improcess'], # Chose the same as "name" | ||
version = '0.1.1', # Start with a small number and increase it with every change you make | ||
version = '1.0', # Start with a small number and increase it with every change you make | ||
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository | ||
description = 'This short little python module can help you with running your iteratable functions on multi process without any hassle of creating process by yourself.', # Give a short description about your library | ||
author = 'Nitin Rai', # Type in your name | ||
author_email = '[email protected]', # Type in your E-Mail | ||
url = 'https://github.com/imneonizer/improcess', # Provide either the link to your github or to your website | ||
download_url = 'https://github.com/imneonizer/improcess/archive/v0.1.1.tar.gz', # I explain this later on | ||
download_url = 'https://github.com/imneonizer/improcess/archive/v1.0.tar.gz', # I explain this later on | ||
keywords = ['Multi Processing', 'Synchronous Processing', 'Parallel execution'], # Keywords that define your package best | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import improcess | ||
import random | ||
import time | ||
|
||
names = ['April', 'May'] | ||
|
||
#the function for processing data | ||
def my_func(data): | ||
improcess.console_log(output=True) | ||
name = random.choice(names) | ||
time.sleep(1) | ||
return f'{name} says, Hello World!' | ||
|
||
if __name__=="__main__": | ||
processed_data = improcess.start(my_func, repeat=4) | ||
|
||
print(processed_data) | ||
improcess.elapsed(output=True) |