Skip to content

Commit

Permalink
Merge pull request #26 from abhishekgupta368/add_multithreading@abhis…
Browse files Browse the repository at this point in the history
…hekgupta368

added_multiprocessing
  • Loading branch information
rajatkb authored Mar 13, 2020
2 parents 6c2eec8 + b68363e commit c5759f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions Scrapper-Service/process/mutiprocessing.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
from utility import get_logger , print_start

from multiprocessing import Process
## TO_DO
## 1. Add multiprocessing from the reference implementation
## 2. Use Logging at properplaces for generating logs from the context manager
class MultiProcessingContext:

def __init__(self , log_level , log_stream):
"""[Multi Processing class]
Responsible for running the lambda functions passed in
inside threads
Arguments:
log_level {[string]} -- Levels of log for each process
log_stream {[string]} -- Stream of log for each process
"""
self.logger = get_logger(__name__ , log_level , log_stream)

pass
self.process_list=[]
def __execute__(self , runnable):
runnable()
pass
"""Start execution of MultiProcessingContext
Returns:
None
"""
self.logger.info('''
Thread Process initiated
''')
## start process for each call
p= Process(target= runnable)
## append the each process in list
self.process_list.append(p)
## start calling process
p.start()

def __enter__(self):
return self.__execute__

def __exit__(self , exception_type, exception_value, traceback):
pass
## job of each process is completed
for process in self.process_list:
process.join()


## A HELPER IMPLEMENTATION
# class MultiPoc:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c5759f5

Please sign in to comment.