# Multiprocessing in Python

**URL:** https://community.unix.com/t/multiprocessing-in-python/370234
**Category:** Shell Programming and Scripting
**Created:** [January 5, 2018, 8:37pm UTC](https://community.unix.com/t/multiprocessing-in-python/370234 "2018-01-05T20:37:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alvinoo](https://community.unix.com/letter_avatar/alvinoo/32/5_5575768a8748004e209b776fc1b2916d.png) [@alvinoo](https://community.unix.com/u/alvinoo)
#### Post date: [January 5, 2018, 8:37pm UTC](https://community.unix.com/t/multiprocessing-in-python/370234/1 "2018-01-05T20:37:41Z")

</div>

Hi there,

I have a code that can take in any function with two arguements and do processing. However, I would like to implement a feature whether it can limit a number of process running concurrently so as not take up too much resources. I have tried researching for pool.map however I am unable to find solution pertaining to this.

Tried searching for pool.map it shows something like pool (func, iterable, chunksize=NONE), but unsure how to replace it

```nohighlight
def multProc(targetin, scanip, port):
    jobs = []
    #pool = multiprocessing.Pool(multiprocessing.cpu_count()) ##8 
    p = multiprocessing.Process(target=targetin, args=(scanip,port))
    jobs.append(p)
    p.start()
    return

```

---

<div class="post-metadata">

### Author: ![balajesuri](https://community.unix.com/user_avatar/community.unix.com/balajesuri/32/1423_2.png) [@balajesuri](https://community.unix.com/u/balajesuri)
#### Post date: [January 6, 2018, 9:24am UTC](https://community.unix.com/t/multiprocessing-in-python/370234/2 "2018-01-06T09:24:39Z")

</div>

Check the [multiprocessing.Pool](https://docs.python.org/2/library/multiprocessing.html#module-multiprocessing.pool) class. The example in the docs give a good insight on how to implement.
