[Tutor] Multiprocessing with many input input parameters

Shall, Sydney sydney.shall at kcl.ac.uk
Fri Jul 12 07:53:16 EDT 2019


Thanks Mike,

But I am still not clear.

do I write:

def f([x,y,z]) ?
How exactly do one write the function and how does one ensure that each positional argument is accounted for.

Dr. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01
________________________________
From: Mike Barnett <mike_barnett at hotmail.com>
Sent: 11 July 2019 16:40
To: Shall, Sydney
Cc: tutor at python.org
Subject: RE: [Tutor] Multiprocessing with many input input parameters

If you're passing parameters as a list, then you need a "," at the end of the items.  Otherwise if you have something like a string as the only item, the list will be the string.

list_with_one_item = ['item one',]


@mike

-----Original Message-----
From: Shall, Sydney <sydney.shall at kcl.ac.uk>
Sent: Wednesday, July 10, 2019 11:44 AM
To: tutor at python.org
Subject: [Tutor] Multiprocessing with many input input parameters

I am using MAC OS X 10.14.5 on a MAC iBook I use Python 3.7.0 from Anaconda, with Spyder 3.3.3

I am a relative beginner.

My program models cell reproduction. I have written a program that models this and it works.

Now I want to model a tissue with several types of cells. I did this by simply rerunning the program with different inputs (cell characteristics). But now I want to send and receive signals between the cells in each population. This requires some sort of concurrent processing with halts at appropriate points to pass and receive signals.

I thought to use multiprocessing. I have read the documentation and reproduced the models in the docs. But I cannot figure out how to feed in the data for multiple parameters.

I have tried using Pool and it works fine, but I can only get it to accept 1 input parameter, although multiple data inputs with one parameter works nicely.

So, my questions are;

  1.  Is multiprocessing the suitable choice.
  2.  if yes, how does one write a function with multiple input parameters.

Thank s in advance.

Sydney

Prodessor. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01



More information about the Tutor mailing list