You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import util
|
|
|
|
import multiprocessing
|
|
|
|
|
|
|
|
|
|
|
|
@util.measure_performance
|
|
|
|
def compute_task():
|
|
|
|
processes = [
|
|
|
|
multiprocessing.Process(target=util.compute_task) for _ in range(5)
|
|
|
|
]
|
|
|
|
for process in processes:
|
|
|
|
process.start()
|
|
|
|
for process in processes:
|
|
|
|
process.join()
|
|
|
|
|
|
|
|
|
|
|
|
@util.measure_performance
|
|
|
|
def io_task():
|
|
|
|
processes = [
|
|
|
|
multiprocessing.Process(target=util.fetch_url, args=(url, ))
|
|
|
|
for url in util.urls
|
|
|
|
]
|
|
|
|
for process in processes:
|
|
|
|
process.start()
|
|
|
|
for process in processes:
|
|
|
|
process.join()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
compute_task()
|
|
|
|
io_task()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|